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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |INVALID
                 CC|                            |msebor at gcc dot gnu.org

--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
Both the warning and the analysis in comment #0 are correct.  The code tries to
allocate an excessively large VLA (the -1 converts to SIZE_MAX):

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

In function ‘bar’,
    inlined from ‘baz’ at pr91235.c:14:5:
pr91235.c:7:14: warning: argument to variable-length array is too large
[-Wvla-larger-than=]
    7 |         char a[(int)(n == 2 ? -1 : 0)];
      |              ^
pr91235.c:7:14: note: limit is 9223372036854775807 bytes, but argument is
18446744073709551615
void baz ()
{
  char[0:D.1971] * a.2;
  void * saved_stack.3_2;

  <bb 2> [local count: 1073741824]:
  saved_stack.3_2 = __builtin_stack_save ();
  a.2_3 = __builtin_alloca_with_align (18446744073709551615, 8);   <<<
-Wvla-larger-than
  foo (a.2_3);
  __builtin_stack_restore (saved_stack.3_2);
  return;

}

Reply via email to