https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111775
Bug ID: 111775 Summary: -Wstrict-flex-arrays missing diagnostics with unions Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: crrodriguez at opensuse dot org Target Milestone: --- following code is not diagnosed #include <stddef.h> #include <stdlib.h> #include <stdio.h> struct foo { int dum; union { /* or [1] */ char a[0]; wchar_t b[0]; } fn; }; int main(void) { struct foo *f = malloc(sizeof(*f)); /* or really any use of the union does not matter */ printf("%p", f->fn.b); free(f); return 0; } compile options -Wall -fstrict-flex-arrays -Werror=strict-flex-arrays -O2 This test is a silly mockup of real widespread code, which goes undiagnosed until test suites run and/or is built with ubsan.