https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116885
--- Comment #20 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Jaroslav Fojtík from comment #0) > jara@cfarm421:~/mintest$ make > gcc -I./ -Wall -g -O2 -c struct.c -o struct.o > gcc -I./ -Wall -g -O2 -c mintest.c -o mintest.o > gcc -lm -o mintest struct.o mintest.o > > I have also tested option -O0 without any positive effect. The commands above already use -O0 so that is not changing anything. > <<<struct>>> (c)1998-2024 Jaroslav Fojtik > This program tests the struct.c library > ***LO_ENDIAN defined*** > ***NATIVE access*** > Testing struct manipulation > Segmentation fault If I use -fsanitize=undefined then I get a segfault on x86_64-pc-linux-gnu using every version of GCC from 6.1 onwards. There are also errors reported by valgrind. Even without -fsanitize=undefined I see errors with GCC 13 on x86_64-pc-linux-gnu in a Fedora 39 container: <<<struct>>> (c)1998-2024 Jaroslav Fojtik This program tests the struct.c library ***LO_ENDIAN defined*** ***NATIVE access*** Testing struct manipulation Wrong value read from struct SU.TileCompression 176, expected 2 Wrong value read from struct SU.TileByteCounts -1357445104, expected 2077093650 Wrong value read from struct SU.xRasMin 0.000000, expected -100.500000 Wrong value read from struct SU.Dummy "", expected "Hello word from struct test". Unit Error 4 (In reply to Jaroslav Fojtík from comment #17) > All the previous GCCs from 2.95 till 13 did not crash on this and worked as > expected. That doesn't seem to be true. Both UBsan and valgrind reveal problems in the code.