https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67193
Bug ID: 67193 Summary: Overzealous -Wstack-usage warning Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: tobi at gcc dot gnu.org Target Milestone: --- -Wstack-usage throws a warning if it cannot prove that the stack is bounded. Therefore it is more noisy with optimization turned off. That is fine, but sometimes it's really too noisy, such as in this example (this is with current trunk): $ cat t.cc #include <alloca.h> void f(char *p) { char *q = (char*)alloca(1); *q = *p; return; } $ bin/g++ -c -Wstack-usage=898989 t.cc t.cc: In function ‘void f(char*)’: t.cc:3:6: warning: stack usage might be unbounded [-Wstack-usage=] void f(char *p) { ^ $ bin/g++ -O -c -Wstack-usage=898989 t.cc $ bin/g++ --version g++ (GCC) 6.0.0 20150812 (experimental) Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. $ Constant folding should suffice to get rid of this warning but apparently alloca is converted to some more complicated operation before the warning is issued. (I know that alloca with a fixed argument is fairly pointless, but this can happen with templates.)