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 #48

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

Build fails with strict-aliasing violations #48

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

Comments

@eli-schwartz
Copy link

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

The -Werror=* flags are important to detect cases where the compiler can try to optimize based on assuming UB cannot happen, and miscompile code that has UB in it. strict-aliasing issues are always bad but LTO can make them even worse.

I got this error:

x86_64-pc-linux-gnu-g++ -DHAVE_CONFIG_H -I.  -DCONFDIR='"/etc"'    -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 -c -o portspoof-connection.o `test -f 'connection.cpp' || echo './'`connection.cpp
connection.cpp: In function ‘void* process_connection(void*)’:
connection.cpp:92:22: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
   92 |         int tid =  *((int*)(&arg));
      |                     ~^~~~~~~~~~~~~
cc1plus: some warnings being treated as errors
make[2]: *** [Makefile:455: portspoof-connection.o] Error 1

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

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

1 participant