Why does C++ allow variable length arrays that aren’t dynamically allocated?

Support for variable length arrays (VLAs) was added to the C language in C99.

It’s likely that since support for them exists in gcc (to support C99), it was relatively straightforward to add support for them to g++.

That said, it’s an implementation-specific language extension, and it’s not a good idea to use implementation-specific extensions if you want your code to be portable.

Leave a Comment