I\'m not a C++ expert, but as far as I know this code should fail due to size not being constant:
#include
using namespace std;
c99 supports variable length arrays(VLA) but neither c90 nor C++ supports variable length arrays, but gcc support this as an extension in both C and C++ you can see this more clearly if you compile with these arguments:
gcc -std=c89 -pedantic
this will give you the following warning:
warning: ISO C90 forbids variable length array ‘array’ [-Wvla]
or with g++:
g++ -pedantic
will give you this warning:
warning: ISO C++ forbids variable length array ‘array’ [-Wvla]
this standards section in the gcc manual goes into more details. Important to note that as of the 2011 C standard variable length arrays(VLA) are now optional.