https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100425

            Bug ID: 100425
           Summary: missing -Walloca-larger-than with -O0
           Product: gcc
           Version: 11.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

The gimple-ssa-warn-alloca.c pass only both with and without optimization and
-Walloca triggers when it's enabled but the more useful -Walloca-larger-than
fails to diagnose the excessive constant allocations because at -O0 the pass
only runs when -Walloca is enabled and not when -Walloca-larger-than.  The pass
should run for both warning options even at -O0 and only diagnose the subset it
can reliably detect.

$ cat z.c && gcc -S -Wall -fdump-tree-lower=/dev/stdout
-Walloca-larger-than=100 z.c 
void f (void*);

void g (void)
{
  f (__builtin_alloca (1234));
}

#pragma GCC diagnostic error "-Walloca"

void h (void)
{
  f (__builtin_alloca (1234));
}


;; Function g (g, funcdef_no=0, decl_uid=1945, cgraph_uid=1, symbol_order=0)

void g ()
{
  _1 = __builtin_alloca (1234);
  f (_1);
  return;
}



;; Function h (h, funcdef_no=1, decl_uid=1948, cgraph_uid=2, symbol_order=1)

void h ()
{
  _1 = __builtin_alloca (1234);
  f (_1);
  return;
}


z.c: In function ‘h’:
z.c:12:3: error: use of ‘alloca’ [-Werror=alloca]
   12 |   f (__builtin_alloca (1234));
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors

Reply via email to