https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96228
Bug ID: 96228
Summary: -Wstack-usage does not understand constant
__builtin_alloca calls
Product: gcc
Version: 9.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: analyzer
Assignee: dmalcolm at gcc dot gnu.org
Reporter: renat at idrisov dot info
Target Milestone: ---
Hi All,
when compiling the following piece of code:
```
#include <stdio.h>
int main(void) {
char *a = __builtin_alloca(4);
a[0] = 0;
printf("%c", a[0]);
return 0;
}
```
with:
$ gcc -Wstack-usage=2048 stack.c
gives:
stack.c:3:5: warning: stack usage might be unbounded [-Wstack-usage=]
3 | int main(void) {
which is too pessimistic on `__builtin_alloca` behavior.
No warning when "char *a = __builtin_alloca(4);" is changed to "char a[4];"
Thank you!