g++ variable size array no warning?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: int a; cin >> a; int ints[a]; Why does this not throw any kind of warning while compiling? How do I know when this array thing is actually using the heap or the stack? g++ -std=c++11 -Wall *.cpp -o main 回答1: 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 .