G++ accepts definitions of C flexible array members as an extension. However, since C specifies that a flexible array member has an incomplete type, such a member is not a valid operand in expressions that require an object to have a complete type. An example is the sizeof expression. Since flexible array members are provided for compatibility with C, they should be subject to the same requirements and restrictions. $ cat z.cpp && /build/gcc-trunk-svn/gcc/xgcc -B /build/gcc-trunk-svn/gcc -Wall -Wextra -Wpedantic -xc++ z.cpp struct S { int n; int a[]; } s; extern int a[]; enum E { e = sizeof s.a, // rejected in C, accepted in C++ f = sizeof a // rejected in both C and C++ }; z.cpp:3:11: warning: ISO C++ forbids zero-size array ‘a’ [-Wpedantic] int a[]; ^ z.cpp:10:16: error: invalid application of ‘sizeof’ to incomplete type ‘int []’ f = sizeof a // rejected in both C and C++ ^
Patch posted for review: https://gcc.gnu.org/ml/gcc-patches/2015-12/msg00511.html
Fixed in r231665.