I know that in C99 you can declare a array which size is the value of a parameter, like this:
void foo(int size) {
int array[size];
// do stuff
}
From what I understand, it is allocated on the stack when the function is called. Apparently this is not supposed to works in C++.
Recently I wrote something like this in C++:
void bar(vector<Thing> vec) {
for (Thing t : vec) {
int n = t.get_n();
int array[n];
// do stuff
}
}
Surprisingly the compiler (G++) did not complain, why? Is there an hidden memory allocation there?