compile failure on ubuntu: taking address of packed member of may result in an unaligned pointer value
❯ 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.
This is important for troubleshooting. Please attach at least the following info:
Describe your issue
compile failure on ubuntu: taking address of packed member of may result in an unaligned pointer value
bug report
compile failure
compile success
under ubuntu 20.04, run command
make allwill reproduce this issue.error logs:
Describe your running environment
This is important for troubleshooting. Please attach at least the following info:
cat /etc/os-release):NAME="Ubuntu"
VERSION="20.04.2 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.2 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
uname -a):Linux ubuntu 5.8.0-55-generic #62~20.04.1-Ubuntu SMP Wed Jun 2 08:55:04 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux