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

Build fails with strict-aliasing violations #287

Open
eli-schwartz opened this issue Mar 5, 2024 · 0 comments
Open

Build fails with strict-aliasing violations #287

eli-schwartz opened this issue Mar 5, 2024 · 0 comments
Assignees
Labels

Comments

@eli-schwartz
Copy link

Description

FAILED: tests/CMakeFiles/test_pfx.dir/test_pfx.c.o 
/usr/bin/x86_64-pc-linux-gnu-gcc  -I/var/tmp/portage/net-libs/rtrlib-0.8.0/work/rtrlib-0.8.0/.  -march=native -fstack-protector-all -O2 -pipe -fdiagnostics-color=always -frecord-gcc-switches -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-clash-protection -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing  -Wformat -Werror=format-security -Werror=implicit-function-declaration -Werror=implicit-int -Werror=int-conversion -Werror=incompatible-pointer-types -Wall -std=gnu99 -fstack-protector-all -MD -MT tests/CMakeFiles/test_pfx.dir/test_pfx.c.o -MF tests/CMakeFiles/test_pfx.dir/test_pfx.c.o.d -o tests/CMakeFiles/test_pfx.dir/test_pfx.c.o -c /var/tmp/portage/net-libs/rtrlib-0.8.0/work/rtrlib-0.8.0/tests/test_pfx.c
/var/tmp/portage/net-libs/rtrlib-0.8.0/work/rtrlib-0.8.0/tests/test_pfx.c: In function ‘mass_test’:
/var/tmp/portage/net-libs/rtrlib-0.8.0/work/rtrlib-0.8.0/tests/test_pfx.c:132:54: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
  132 |                 ((uint64_t *)pfx.prefix.u.addr6.addr)[0] = min_i + i;
      |                                                      ^
/var/tmp/portage/net-libs/rtrlib-0.8.0/work/rtrlib-0.8.0/tests/test_pfx.c:152:54: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
  152 |                 ((uint64_t *)pfx.prefix.u.addr6.addr)[0] = min_i + i;
      |                                                      ^
/var/tmp/portage/net-libs/rtrlib-0.8.0/work/rtrlib-0.8.0/tests/test_pfx.c:176:54: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
  176 |                 ((uint64_t *)pfx.prefix.u.addr6.addr)[0] = min_i + i;
      |                                                      ^
cc1: some warnings being treated as errors

Steps to reproduce the issue

I tried to compile with the following flags for LTO: -flto=4 -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing

The -Werror's here are very important, because LTO can optimize based on the assumption that certain language requirements are met, and if they aren't met, a miscompilation happens.

Actually, strict-aliasing can cause issues even without LTO ;) but LTO does tend to make them worse.

Downstream report: https://bugs.gentoo.org/861581
Full build logs: build.log

Versions

Operating system: Gentoo Linux
Build environment: GCC
rtrlib: 0.8.0

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

No branches or pull requests

3 participants