[Bug middle-end/96228] -Wstack-usage does not understand constant __builtin_alloca calls

ebotcazou at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Jul 17 08:51:10 GMT 2020


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

Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ebotcazou at gcc dot gnu.org

--- Comment #3 from Eric Botcazou <ebotcazou at gcc dot gnu.org> ---
The reason is rather that no flow analysis is performed by -Wstack-usage, which
means that it cannot distinguish:

int main(void) {
  char *a = __builtin_alloca(4);
  a[0] = 0;
  __builtin_printf("%c", a[0]);
  return 0;
}

from

int main(void) {
  while (1) {
     char *a = __builtin_alloca(4);
     a[0] = 0;
     __builtin_printf("%c", a[0]);
  }

  return 0;
}

so it assumes the worst.


More information about the Gcc-bugs mailing list