This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Constant expression for array subscript operator


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          


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]