#include<iostream>
using namespace std;
main()
{
int m;
cin>>m;
int re[m];
cout<<sizeof(re);
}
This code is running perfectly in codeforces GNU C++ 4.7. But why?? shouldn't the array size be a constant.
#include<iostream>
using namespace std;
main()
{
int m;
cin>>m;
int re[m];
cout<<sizeof(re);
}
This code is running perfectly in codeforces GNU C++ 4.7. But why?? shouldn't the array size be a constant.
| # | User | Rating |
|---|---|---|
| 1 | jiangly | 3810 |
| 2 | Benq | 3676 |
| 3 | Kevin114514 | 3655 |
| 4 | maroonrk | 3463 |
| 5 | strapple | 3390 |
| 6 | Um_nik | 3387 |
| 7 | tourist | 3384 |
| 8 | heuristica | 3322 |
| 9 | turmax | 3319 |
| 10 | jiangbowen | 3291 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 155 |
| 2 | nik_exists | 150 |
| 2 | maspy | 150 |
| 4 | Um_nik | 143 |
| 5 | AmShZ | 141 |
| 6 | Errichto | 139 |
| 7 | adamant | 137 |
| 8 | maroonrk | 134 |
| 9 | BledDest | 132 |
| 10 | qwexd | 129 |
| Name |
|---|



Latest GCC versions seem to be able to cope with that. I was shocked as well the first time my friend claimed this is possible in GCC. I agree that it is quite misleading for beginners, because it, kind of, "violates" basic principles of "what's good and what's wrong" :)
Here is mentioned what to do if you need to have that warning. http://stackoverflow.com/questions/17899274/g-variable-size-array-no-warning