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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2021-01-21 00:00:00         |2021-12-15
      Known to fail|11.0                        |11.2.0, 12.0

--- Comment #11 from Martin Sebor <msebor at gcc dot gnu.org> ---
GCC 11 still issues the same -Wstringop-overflow as GCC 10 plus another one for
the call to md_copy_dims():

In function ‘real_from_complex_dims’,
    inlined from ‘md_test’ at pr91707.c:14:4:
pr91707.c:7:13: warning: writing 8 bytes into a region of size 0
[-Wstringop-overflow=]
    7 |    odims[0] = 2;
      |    ~~~~~~~~~^~~
pr91707.c: In function ‘md_test’:
pr91707.c:13:9: note: destination object ‘dimsR.8’ of size 0
   13 |    long dimsR[D + 1];
      |         ^~~~~
In function ‘real_from_complex_dims’,
    inlined from ‘md_test’ at pr91707.c:14:4:
pr91707.c:8:4: warning: ‘md_copy_dims’ accessing 34359738360 bytes in a region
of size 0 [-Wstringop-overflow=]
    8 |    md_copy_dims(D, odims + 1, idims);
      |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
pr91707.c: In function ‘md_test’:
pr91707.c:8:4: note: referencing argument 2 of type ‘long int *’
pr91707.c:2:13: note: in a call to function ‘md_copy_dims’
    2 | extern void md_copy_dims(unsigned int D, long odims[D], const long
idims[D]);
      |             ^~~~~~~~~~~~

The second warning is for the md_copy_dims() call in the following IL:

  <bb 5> [count: 0]:
  md_copy_dims (4294967295, &MEM <unsigned char[0:18446744073709551615]> [(void
*)&dimsR.8 + 8B], idims_13(D));
  __builtin___ubsan_handle_vla_bound_not_positive (&*.Lubsan_data1, 0);

  <bb 6> [local count: 1073741824]:
  dimsR.8 ={v} {CLOBBER};
  return;

The first warning is gone in GCC 12 and only the second one remains.  It's
triggered by the same md_copy_dims() call with the first argument in excess of
the size of the arrays passed to the function:

  <bb 7> [count: 0]:
  _29 = dimsR.1_23 + 8;
  md_copy_dims (4294967295, _29, idims_13(D));
  __builtin___ubsan_handle_vla_bound_not_positive (&*.Lubsan_data1, 0);

Reply via email to