ISO C++ disallows the use of variable length arrays, which g++
happily tells you if you increase the strictness of it by passing it the -pedantic
flag.
Using -pedantic
will issue a warning about things breaking the standard. If you want g++
to issue an error and with this refuse compilation because of such things; use -pedantic-errors
.
g++ -Wall -pedantic -std=c++11 apa.cpp
apa.cpp: In function ‘int main(int, char**)’:
apa.cpp:8:13: warning: ISO C++ forbids variable length array ‘ints’ [-Wvla]
int ints[a];
^
apa.cpp:8:7: warning: unused variable ‘ints’ [-Wunused-variable]
int ints[a];
^
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…