https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112539
Xi Ruoyao <xry111 at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |xry111 at gcc dot gnu.org --- Comment #3 from Xi Ruoyao <xry111 at gcc dot gnu.org> --- This invalid bug report is actually not related to flexible array member. It's just invoking an undefined behavior. With -fsanitize=undefined -fno-sanitize-recover: t.c:13:19: runtime error: store to address 0x7ffd20f7fb30 with insufficient space for an object of type 'char' 0x7ffd20f7fb30: note: pointer points here 00 00 00 00 00 00 00 00 00 00 00 00 00 c7 f6 e9 8f 37 ae d2 68 fc f7 20 fd 7f 00 00 00 00 00 00 ^ In C even int a[1]; return a[114514]; will compile. But it triggers an undefined behavior at runtime. An undefined behavior may cause a program crash, output some garbage, or "behave as you expected" if you are lucky.