gcc/g++ not ISO compliance?
Vincent Rivellino
vrivelli@cs.vt.edu
Mon Jan 13 05:17:00 GMT 2003
Thanks for the insight. I knew there had to be a logical explanation
behind this.
-Vince
On Fri, 10 Jan 2003, Volker Reichelt wrote:
> 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
>
>
More information about the Gcc-bugs
mailing list