GCC gives an error "variable-size type declared outside of any function" for code such as:
int a; int b = sizeof (int (*)[a]); As far as I can tell there is no basis for this in C99; the sizeof expression certainly has result an integer constant in this case and its operand is not evaluated. It's declarations of ordinary identifiers with variably modified type that aren't allowed outside functions. Similarly, casts to variably modified types should be permitted at file scope under similar circumstances to those accepted in static initializers in gcc.dg/c99-const-expr-11.c (and gnu99-const-expr-3.c). -- Summary: VLA types at file scope wrongly rejected Product: gcc Version: 4.5.0 Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: jsm28 at gcc dot gnu dot org OtherBugsDependingO 16989 nThis: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39581