Opened 8 months ago

Last modified 8 months ago

#15039 new defect

TOOLS: Build fails with strict-aliasing violations

Reported by: eli-schwartz Owned by:
Priority: normal Component: Tools
Version: Keywords:
Cc: Game:

Description

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++ -MMD -MF "engines/grim/luac/.deps/dump.d" -MQ "engines/grim/luac/dump.o" -MP -Wall -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  -DNDEBUG -g -W -Wno-unused-parameter -Wno-empty-body -std=c++11  -I/usr/include/freetype2 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -Wno-long-long -Wno-multichar -Wno-unknown-pragmas -Wno-reorder -Wpointer-arith -Wcast-qual -Wshadow -Wnon-virtual-dtor -Wwrite-strings -fcheck-new -DHAVE_CONFIG_H -DPOSIX -I. -I. -I/usr/include/libpng16  -c engines/grim/luac/dump.cpp -o engines/grim/luac/dump.o
engines/grim/luac/dump.cpp: In function ‘void DumpFloat(float, FILE*)’:
engines/grim/luac/dump.cpp:31:31: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
   31 |         WRITE_LE_UINT32(out, *(uint32*)(&f));
      |                               ^~~~~~~~~~~~~
cc1plus: some warnings being treated as errors
make: *** [Makefile.common:531: engines/grim/luac/dump.o] Error 1

Downstream report: https://bugs.gentoo.org/926081

Attachments (1)

build.log (281.8 KB ) - added by eli-schwartz 8 months ago.

Download all attachments as: .zip

Change History (2)

by eli-schwartz, 8 months ago

Attachment: build.log added

comment:1 by tag2015, 8 months ago

Summary: Build fails with strict-aliasing violationsTOOLS: Build fails with strict-aliasing violations
Note: See TracTickets for help on using tickets.