In C99, the brackets must contain an assignment-expression, however, "2, 3" is not an assignment-expression. I don't have the C89 standard, but I guess it's similar. It would be nice to reject this code, because it's a totally useless language extension, and it might confuse newbies trying to declare two-dimensional arrays.
[forwarded from http://bugs.debian.org/177303]
I can confirm this on the mainline (20030815). The problem is that in the c-parse.y (really c-parse.in) The array_declarator is defined as follows: array_declarator: '[' maybe_type_quals_attrs expr ']' { $$ = build_array_declarator ($3, $2, 0, 0); } | '[' maybe_type_quals_attrs ']' { $$ = build_array_declarator (NULL_TREE, $2, 0, 0); } | '[' maybe_type_quals_attrs '*' ']' { $$ = build_array_declarator (NULL_TREE, $2, 0, 1); } | '[' STATIC maybe_type_quals_attrs expr ']' { $$ = build_array_declarator ($4, $3, 1, 0); } /* declspecs_nosc_nots is a synonym for type_quals_attrs. */ | '[' declspecs_nosc_nots STATIC expr ']' { $$ = build_array_declarator ($4, $2, 1, 0); } ; which is different from what C99 says.
Subject: Bug 11943 CVSROOT: /cvs/gcc Module name: gcc Changes by: jsm28@gcc.gnu.org 2003-10-24 15:30:37 Modified files: gcc : ChangeLog c-parse.in gcc/testsuite : ChangeLog Added files: gcc/testsuite/gcc.dg: c99-arraydecl-2.c Log message: * c-parse.in (array_declarator): Use expr_no_commas. Fixes PR c/11943. testsuite: * gcc.dg/c99-arraydecl-2.c: New test. PR c/11943. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.1542&r2=2.1543 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-parse.in.diff?cvsroot=gcc&r1=1.187&r2=1.188 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3143&r2=1.3144 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/c99-arraydecl-2.c.diff?cvsroot=gcc&r1=NONE&r2=1.1
Fixed for 3.4.