Skip to content

compile failure: taking address of packed member of may result in an unaligned pointer value #31

@WinnieeBear

Description

@WinnieeBear

Describe your issue

compile failure on ubuntu: taking address of packed member of may result in an unaligned pointer value

  • Is this a bug report or a feature request?
    bug report
  • Describe the issue
    compile failure
  • What is the expected behaviour?
    compile success
  • How to reproduce the problem?
    under ubuntu 20.04, run command make all will reproduce this issue.

error logs:

❯ make all
cc  -I include -Wall -Werror -pthread -c src/skbuff.c -o build/skbuff.o
cc  -I include -Wall -Werror -pthread -c src/socket.c -o build/socket.o
cc  -I include -Wall -Werror -pthread -c src/ip_input.c -o build/ip_input.o
cc  -I include -Wall -Werror -pthread -c src/tuntap_if.c -o build/tuntap_if.o
cc  -I include -Wall -Werror -pthread -c src/icmpv4.c -o build/icmpv4.o
cc  -I include -Wall -Werror -pthread -c src/netdev.c -o build/netdev.o
cc  -I include -Wall -Werror -pthread -c src/tcp.c -o build/tcp.o
cc  -I include -Wall -Werror -pthread -c src/cli.c -o build/cli.o
cc  -I include -Wall -Werror -pthread -c src/tcp_data.c -o build/tcp_data.o
cc  -I include -Wall -Werror -pthread -c src/sock.c -o build/sock.o
cc  -I include -Wall -Werror -pthread -c src/tcp_output.c -o build/tcp_output.o
cc  -I include -Wall -Werror -pthread -c src/arp.c -o build/arp.o
cc  -I include -Wall -Werror -pthread -c src/route.c -o build/route.o
cc  -I include -Wall -Werror -pthread -c src/ipc.c -o build/ipc.o
src/ipc.c: In function ‘ipc_connect’:
src/ipc.c:164:41: error: taking address of packed member of ‘struct ipc_connect’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
  164 |     rc = _connect(pid, payload->sockfd, &payload->addr, payload->addrlen);
      |                                         ^~~~~~~~~~~~~~
src/ipc.c: In function ‘ipc_getsockopt’:
src/ipc.c:275:79: error: taking address of packed member of ‘struct ipc_sockopt’ may result in an unaligned pointer value [-Werror=address-of-packed-member]
  275 |     rc = _getsockopt(pid, opts->fd, opts->level, opts->optname, opts->optval, &opts->optlen);
      |                                                                               ^~~~~~~~~~~~~
cc1: all warnings being treated as errors
make: *** [Makefile:15: build/ipc.o] Error 1
❯ gcc --version
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Describe your running environment

This is important for troubleshooting. Please attach at least the following info:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions