This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: gcc/g++ not ISO compliance?
- From: Volker Reichelt <reichelt at igpm dot rwth-aachen dot de>
- To: vrivelli at cs dot vt dot edu
- Cc: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 10 Jan 2003 17:22:09 +0100
- Subject: Re: gcc/g++ not ISO compliance?
Variable sized errors are a GCC extension, see
http://gcc.gnu.org/onlinedocs/gcc-3.2.1/gcc/Variable-Length.html#Variable%20Length
If you want to have strict ISO compliance you can specify the command line
option "-pedantic" which gives you are warning
code.cc: In function `int main()':
code.cc:9: warning: ISO C++ forbids variable-size array `array'
or "-pedantic-errors" which gives you an error
code.cc: In function `int main()':
code.cc:9: error: ISO C++ forbids variable-size array `array'
for the following code:
-----------------------------snip here------------------------
#include<iostream>
using namespace std;
int main()
{
int i;
cin>>i;
int array[ i ]; // i is dynamic
cout<<endl;
for (int j=0; j<i; j++) // see if there is any run-time error
cout<<array[j]<<endl;
return 0;
}
-----------------------------snip here------------------------
Regards,
Volker