Variable length array may produce the error: "size of array `arr' is too large".

Tanaka Akira akr@jaist.ac.jp
Wed Oct 13 08:03:00 GMT 1999


% cat tst.c
int num;

void
fun(void)
{
  int arr[num + 1];
}
% /app/gcc-2.95.1/bin/gcc -v --save-temps -c tst.c
Reading specs from /app/gcc-2.95.1/lib/gcc-lib/sparc-sun-solaris2.7/2.95.1/specs
gcc version 2.95.1 19990816 (release)
 /app/gcc-2.95.1/lib/gcc-lib/sparc-sun-solaris2.7/2.95.1/cpp -lang-c -v -D__GNUC__=2 -D__GNUC_MINOR__=95 -Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 -D__sparc__ -D__sun__ -D__unix__ -D__svr4__ -D__SVR4 -D__sparc -D__sun -D__unix -Asystem(unix) -Asystem(svr4) -D__GCC_NEW_VARARGS__ -Acpu(sparc) -Amachine(sparc) tst.c tst.i
GNU CPP version 2.95.1 19990816 (release) (sparc)
#include "..." search starts here:
#include <...> search starts here:
 /app/gcc-2.95.1/include
 /app/gcc-2.95.1/lib/gcc-lib/sparc-sun-solaris2.7/2.95.1/../../../../sparc-sun-solaris2.7/include
 /app/gcc-2.95.1/lib/gcc-lib/sparc-sun-solaris2.7/2.95.1/include
 /usr/include
End of search list.
The following default directories have been omitted from the search path:
 /app/gcc-2.95.1/lib/gcc-lib/sparc-sun-solaris2.7/2.95.1/../../../../include/g++-3
End of omitted list.
 /app/gcc-2.95.1/lib/gcc-lib/sparc-sun-solaris2.7/2.95.1/cc1 tst.i -quiet -dumpbase tst.c -version -o tst.s
GNU C version 2.95.1 19990816 (release) (sparc-sun-solaris2.7) compiled by GNU C version 2.95 19990728 (release).
tst.c: In function `fun':
tst.c:6: size of array `arr' is too large
zsh: exit 1     /app/gcc-2.95.1/bin/gcc -v --save-temps -c tst.c
% 

It should not produce an error.
-- 
Tanaka Akira


More information about the Gcc-bugs mailing list