https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86247
Bug ID: 86247 Summary: warning on alloca within a loop overly restrictive for constant loops Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- The usability of the-Walloca-larger-than= warnings could be improved by taking into consideration the product of the upper bound on the number of iterations of the loop and the alloca argument. For example, the loop in the following test case effectively results in allocating just 32 * 17 or 544 bytes, well below the 4K limit set by the -Walloca-larger-than=4096 option. The warning could be avoided in this case. $ cat c.c && gcc -S -O2 -Wall -Wextra -Walloca-larger-than=4096 c.c void f (void*, ...); void g (void) { for (int i = 0; i != 17; ++i) f (__builtin_alloca (32)); } c.c: In function ‘g’: c.c:6:5: warning: use of ‘alloca’ within a loop [-Walloca-larger-than=] f (__builtin_alloca (32)); ^~~~~~~~~~~~~~~~~~~~~~~~~