Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
WinnieeBear opened this issue Jun 28, 2021 · 3 comments

Comments

@WinnieeBear
Copy link

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:

@Basty9
Copy link

Basty9 commented Jul 16, 2021

Same issue here:

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

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

Linux ubuntu 5.8.0-59-generic #66~20.04.1-Ubuntu SMP Thu Jun 17 11:14:10 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

@ludeen007
Copy link

just remove "-Werror" from "CPPFLAGS" in Makefile file.

@minghu6
Copy link

minghu6 commented Sep 22, 2022

just remove "-Werror" from "CPPFLAGS" in Makefile file.

just add -Wno-address-of-packed-member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants