You are right, af() not a constant expression. Arrays of variable length are not allowed by the C ++ standard. However, the GNU compiler supports them as an extension. You can ask the compiler to give you a warning when using non-standard extensions with the -pedantic or with the -pedantic-errors error.
Edit: Apparently, GCC 4.9 added official support for N3639 , a proposal to add variable-length arrays to the C ++ 14 standard. As a result, the proposal was not included in the standard, but GCC 4.9 was released before C ++ 14, so the changes were not reflected. Thus, VLAs are supported by GCC 4.9 specifically in C ++ 14 mode, and the above parameters do not disable them. Please note that C ++ 14 mode is still experimental (even in GCC 5).
user2079303
source share