This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Constant expression for array subscript operator
- To: gcc at gcc dot gnu dot org
- Subject: Constant expression for array subscript operator
- From: Craig Rodrigues <rodrigc at mediaone dot net>
- Date: Fri, 20 Jul 2001 23:50:03 -0400
Hi,
Should gcc emit an error message on the following piece of
code? gcc 3.0.1 seems to compile it without complaining,
and only issues a warning if I add the -pedantic flag.
#include <cstdio>
void foo(int a)
{
char b[a];
std::printf("Hello %c\n", b[9]);
}
Sun Workshop C++ 5.2 issues an error message:
"a.cpp", line 4: Error: An integer constant expression is required
within the array subscript operator.
Thanks.
--
Craig Rodrigues
http://www.gis.net/~craigr
rodrigc@mediaone.net