https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83172
Eric Botcazou <ebotcazou at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|WAITING |NEW --- Comment #3 from Eric Botcazou <ebotcazou at gcc dot gnu.org> --- > The same result: > > $ gcc-7 -Wvla-larger-than=128 -Wstack-usage=102400 -O0 -c t.c > t.c: In function ‘stack_usage_only’: > t.c:23:5: warning: stack usage might be unbounded [-Wstack-usage=] > int stack_usage_only(unsigned x) > ^~~~~~~~~~~~~~~~ > t.c: In function ‘alloca_fails_even_with_const’: > t.c:32:5: warning: stack usage might be unbounded [-Wstack-usage=] > int alloca_fails_even_with_const() > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > -O1 results the same. Try -Wvla-larger-than=100 though. In any case, note that for: int vla_size_only(unsigned x) { if(x > 128) __builtin_unreachable(); char buf[x]; do_something(buf); return 0; } the warning is expected since the code may allocate more than 128 bytes. -Wstack-usage is designed to be *conservatively* correct and to yield the same result at all optimization levels, i.e. it will never say that the stack usage is bounded if there is a path where it may not be. So it's very different from -Wvla-larger-than or -Walloca-larger-than which say nothing at -O0 or -O1 and are not conservatively correct.