struct Foo { int i; char a[]; } foo = { 1, "" }; // No warning struct Bar { int i; char a[]; } bar = { 1, {0} }; // Warning Line 1 passes -pedantic, but C99 6.7.2.1p16 says it is invalid: Flexible array members are ignored except with ',', '->', and for aligning the size of the struct. Related: Bug 20407: g++ does reject it, even without -pedantic.
Subject: Bug 37481 Author: jsm28 Date: Sun Apr 19 20:38:53 2009 New Revision: 146359 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=146359 Log: PR c/37481 * c-typeck.c (digest_init): Check for initializing an array with a string literal. testsuite: * gcc.dg/c99-flex-array-7.c: New test. Added: trunk/gcc/testsuite/gcc.dg/c99-flex-array-7.c Modified: trunk/gcc/ChangeLog trunk/gcc/c-typeck.c trunk/gcc/testsuite/ChangeLog
Fixed for 4.5.