From mboxrd@z Thu Jan 1 00:00:00 1970 From: allen.everhart@marcgs.com To: gcc-gnats@gcc.gnu.org Cc: jason.ren@marcgs.com;, ashevel.com@sourceware.cygnus.com Subject: c/2591: variable expression erroneously allowed to dimension array Date: Thu, 19 Apr 2001 14:26:00 -0000 Message-id: <20010419212445.26978.qmail@sourceware.cygnus.com> X-SW-Source: 2001-04/msg00345.html List-Id: >Number: 2591 >Category: c >Synopsis: variable expression erroneously allowed to dimension array >Confidential: no >Severity: serious >Priority: high >Responsible: unassigned >State: open >Class: accepts-illegal >Submitter-Id: net >Arrival-Date: Thu Apr 19 14:26:00 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Allen Everhart >Release: gcc version 2.8.1 >Organization: >Environment: AIX 4.2 also is accepted by CodeSorcery /marces/gnu/lib/gcc-lib/powerpc-ibm-aix4.2.1.0/2.8.1/specs >Description: An automatic array is erroneously allowed to be dimensioned by a variable expression. This is an ansi violation and highly nonportable to other ansi compilers. >How-To-Repeat: gcc -Wall -ansi variabledimensionedarray.c >Fix: compile with xlc and fix syntax errors. >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: text/plain; name="variabledimensionedarray.txt" Content-Disposition: inline; filename="variabledimensionedarray.txt" int printf( char *, ... ) ; int i=1 ; int main() { char buff[i] ; /* variable expression allowed to dimension array */ buff[0] = 'f' ; buff[1] = 'o' ; buff[2] = 'o' ; buff[3] = '\0' ; return printf( "%s %d\n", buff, sizeof(buff) ) ; }