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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |msebor at gcc dot gnu.org
     Ever confirmed|0                           |1
      Known to work|                            |10.2.0
          Component|c++                         |tree-optimization
             Status|UNCONFIRMED                 |NEW
            Summary|-Werror=array-bounds false  |[10/11 Regression]
                   |positive:"subscript -1 is   |-Warray-bounds false
                   |outside array bounds"       |positive on varying offset
                   |                            |plus negative
   Last reconfirmed|                            |2021-04-19
      Known to fail|                            |10.3.0, 11.0

--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
Confirmed.  The bug is caused by -Warray-bounds ignoring varying offsets
instead of setting the offset range to that of the referenced object. 
Bisection points to g:e7fd3b783238d034018443e43a58ff87908b4db6 but that just
exposed the underlying bug in the warning.  The test case triggers the false
positive in 10.3.0 and 11.0 but not in 10.2.0 or prior. 

int main ()
{
  ...
  <bb 5> [local count: 114863531]:
  # len_11 = PHI <18446744073709551615(3), len_23(4)>
  s ={v} {CLOBBER};
  s.first_ = &hello;
  iftmp.0_13 = &hello + len_11;                          <<< len_11:
VR_VARYING, iftmp.0_13 taken to point to &hello
  s.last_ = iftmp.0_13;
  _15 = len_11 != 0;
  MEM[(char &)iftmp.0_13 + 18446744073709551615] = 50;   <<< iftmp.0_13[-1] =
'2'; <<< -Warray-bounds
  hello ={v} {CLOBBER};
  s ={v} {CLOBBER};
  return 0;

}

Reply via email to