[Bug c++/35125] New: Violating standards

2008-02-07 Thread amitondemand at gmail dot com
i compiled the following code on  
"Red Hat Linux Enterprise AS Realease 4
 Kernel 2.6.9-5 Elsmp"
and the code was compiled successfully and was running.


//I dont know how this code is working.

#include
using namespace std;

int main()
{
int size;
int arr[size];

cout<<"Enter size of array: ";
cin>>size;


cout<<"Enter values: \n";
for(int i=0; i< size; i++)
cin>>arr[i];

cout<<"Outputting values: \n";
for(int i=0; i< size; i++)
cout

[Bug c++/35125] Violating standards

2008-02-07 Thread amitondemand at gmail dot com


--- Comment #4 from amitondemand at gmail dot com  2008-02-08 06:59 ---
i think this should not work. you should get an error that array size must be
constant.

(In reply to comment #1)
> This code doesn't work reliably.  Change it to
> int main()
> {
> int size;
> cout<<"Enter size of array: ";
> cin>>size;
> int arr[size];
> ...


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35125



[Bug c++/35125] Violating standards

2008-02-07 Thread amitondemand at gmail dot com


--- Comment #5 from amitondemand at gmail dot com  2008-02-08 07:20 ---
As i know C++ doesn't support VLA. Please update me if i m wrong.

(In reply to comment #2)
> VLA in C++ is an extension, if you use -pedantic, you will get an error.
> Also VLA uses the value at the time at definition and no other value after
> wards.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35125