I have a question closely related to this one, the difference being that my code sample does not use new
I repeat here the question:
On page 11 of A Tour of C++ (second edition) is written
The size of an array must be a constant expression.
And the nearby examples indicate he means C-style arrays, not std::array.
So the following:
int main(int argc, char **argv) {
double my_array[argc];
}
should not compile, yet does (GCC 9.3.0, g++ -std=c++17 -Wall
) without warnings.
(This question has a partial answer in Are variable length arrays there in c++? I did not find it because I did not know/forgot about the terminology variable length array. Below I complete this with an answer to my own question that gives a way to force GCC to comply with current ISO.)