https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69338

--- Comment #1 from Martin Sebor <msebor at gcc dot gnu.org> ---
Another test case (derived from the test case in bug 69253), this one even
shows a -Warray-bounds warning with -O2.  With 69253 fixed (and the test case
still accepted), 6.0 also aborts but doesn't print the -Warray-bounds warning.

$ ~/bin/gcc-5.1.0/bin/g++ -O2 -Wall -Wextra -Wpedantic -fpermissive z.c &&
./a.out
z.c:1:22: warning: ISO C++ forbids zero-size array ‘a’ [-Wpedantic]
 struct A { char n, a[]; };
                      ^
z.c: In function ‘int main()’:
z.c:11:37: warning: ISO C++ forbids compound-literals [-Wpedantic]
         int a0 = ((struct A){ 1, "" }).a[0];
                                     ^
z.c:11:37: warning: initializer-string for array of chars is too long
[-fpermissive]
z.c:11:43: warning: array subscript is above array bounds [-Warray-bounds]
         int a0 = ((struct A){ 1, "" }).a[0];
                                           ^
12345678
Aborted (core dumped)


$ /home/msebor/build/gcc-trunk-svn/gcc/xgcc
-B/home/msebor/build/gcc-trunk-svn/gcc -Wall -Wextra -Wpedantic -xc++ -O2 z.c
&& ./a.out
z.c: In function ‘int main()’:
z.c:11:37: warning: ISO C++ forbids compound-literals [-Wpedantic]
         int a0 = ((struct A){ 1, "" }).a[0];
                                     ^

z.c:11:37: warning: initialization of a flexible array member [-Wpedantic]
12345678
Aborted (core dumped)

Reply via email to