-
-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error: variable-sized object may not be initialized #394
Comments
As far as I know, variable length array is not a part of C++ standard, it is a GCC extension. To an extent, clang supports VLA too, but it does not support initialization of such arrays. |
There is an example in C++14 standard (N3690):
But indeed, looks like clang doesn't support VLAs. |
Hello @jetcoder, VLA's are special. They work, even in Clang, if you remove the braced-init. As the size of a VLA is unknown at compile-time, the compiler cannot produce an initializer for it at compile-time. Hence, the following works: int num;
std::cin >> num;
int arr[num]; As this is not a C++ Insights bug, I'm closing this issue. Andreas |
Full error message:
During following code running:
The error is shown for C++ standards from 11 to 20a.
The text was updated successfully, but these errors were encountered: