Currently g++ requires the -pedantic flag to give a warning on a zero sized array that is not the last field in a struct. As far as I can see, this is actually always a significant error if it is not the trailing field in the struct...
Demonstration: temp(510)$ cat zero-size-array.cpp #include <iostream> #include <cstddef> struct bogus { int a; char b[]; int c; } bogus; int main(void) { std::cout << "size of struct bogus =" << sizeof(bogus) << std::endl; std::cout << "offset of field b =" << offsetof(struct bogus, b) << std::endl; std::cout << "offset of field c =" << offsetof(struct bogus, b) << std::endl; return 0; } temp(511)$ g++ -Wall -o zero-size-array zero-size-array.cppsize-array.cppe-array.cpp temp(512)$ zero-size-array size of struct bogus =8 offset of field b =4 offset of field c =4 temp(513)$ g++ -Wall -pedantic -o zero-size-array zero-size-array.cppize-array.cpp zero-size-array.cpp:7: error: ISO C++ forbids zero-size array 'b' temp(514)$ g++ --version g++ (GCC) 4.1.2 20070626 (Red Hat 4.1.2-14) -David -- Summary: g++ should warn or error on internal 0 size array in struct Product: gcc Version: 4.1.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: david dot resnick at comverse dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42121