The following code works fine on my C++ compiler despite the fact that it initializes a variable-sized object.
#include <iostream>
int main() {
int n; std::cin>>n;
int numbers[n]={1,2,3};
}
I'm using g++ 11.2.0 on Ubuntu 21.10. My IDE issues the warning Variable-sized object may not be initialized, but the code still seems to work fine. Why?