https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68489
Bug ID: 68489 Summary: arrays of flexible array members are silently accepted Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- Related to bug 68478, g++ accepts definitions of C flexible array members as an extension for compatibility. However, C doesn't intend to allow declaring arrays of structures containing flexible array members. Such uses are rejected by gcc (with a hard error), and diagnosed either as warnings (Clang) or hard errors (IBM XLC++) in C++ programs. However, as the test case below shows, g++ silently accepts such uses: $ cat z.cpp && /build/gcc-trunk-svn/gcc/xg++ -B /build/gcc-trunk-svn/gcc -Wall -Wextra -Wpedantic -O2 -S -o/dev/null z.cpp struct A { int n; int a []; }; struct A a[2]; // should be diagnosed/rejected z.cpp:3:12: warning: ISO C++ forbids zero-size array ‘a’ [-Wpedantic] int a []; ^