Should you have to ask?
I don't think you should use this feature. The c++ way of allocating a variable-length, contiguous list of elements is using std::vector<int>
. This will give you nice, portable code, and you will not have to care about compiler-dependent behavior, stack size, or any other limitation.
But, if you still want to ask, we first have to decide
Who to ask?
The other answers imply that this is a question about c++, the standardized language. It is not. As the comments have noted, the code you wrote is not standard compliant c++. It makes little sense to reason about it with concepts from the standard when they don't apply*.
This code will only compile with a compiler that provides you an extension that allows you to have variable length arrays. Thus, you have to ask your compiler manufacturer.
gcc
If you are using gcc/g++, their specification is the relevant document, and in their case, it says:
The storage is allocated at the point of declaration and deallocated when the block scope containing the declaration exits.
So: No, you do not have to manually delete or free this memory.
clang
If you are using clang, this page states:
However, Clang supports such variable length arrays for compatibility with GNU C and C99 programs.
So, you can expect their extension to behave compatible to C99, which means you also don't have to manually free anything.
msvc
This question indicates msvc does not support VLAs, so here, you also do not need to manually free anything.
* Of course, when adding a extensions with semantics that look like you're using a local variable, it makes sense that this variable also behaves like a local variable, so from the people developing gcc, I'd expect this to be consistent with the rest of the behavior in c++, but in theory, compiler manufacturers can build their compilers as strange as they want, and they could also make this extension expect you to manually free this memory.