https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107410
Martin Liška <marxin at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |INVALID Status|UNCONFIRMED |RESOLVED --- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> --- Well, the test-case is very fragile and we tend to optimize out another UBSAN stuff (c[i] = 2;). Please provide a test-case that addresses the buffer-overflow due does not contain an UBSAN: $ gcc-12 broken.c -fsanitize=undefined -w && ./a.out broken.c:15:6: runtime error: index 19 out of bounds for type 'char [2]' broken.c:15:10: runtime error: store to address 0x7fffffffd5bd with insufficient space for an object of type 'char' 0x7fffffffd5bd: note: pointer points here d5 ff ff ff 7f 00 00 00 20 01 00 00 00 00 00 e8 d6 ff ff ff 7f 00 00 01 00 00 00 00 00 00 00 b0 ^ broken.c:17:8: runtime error: index 19 out of bounds for type 'char [2]' broken.c:17:8: runtime error: load of address 0x7fffffffd5bd with insufficient space for an object of type 'char' 0x7fffffffd5bd: note: pointer points here d5 ff ff ff 02 00 00 00 20 01 00 00 00 00 00 e8 d6 ff ff ff 7f 00 00 01 00 00 00 00 00 00 00 b0 ^