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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[12/13/14/15 regression]    |[12/13/14 regression] False
                   |False positive report for   |positive report for
                   |Warray-bounds with -O2      |Warray-bounds with -O2

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
So at the point we diagnose we have

D.33765 = std::__find_if.isra (__first, __last, __pred);
D.33767 = D.33765;
it = D.33767;
it_10 = MEM[(struct __normal_iterator *)&it];
if (it_10 != 0B)
  goto <bb 3>; [53.47%]

<bb 3>:
...
<bb 7> [local count: 574129752]:
_50 = (long unsigned int) _44;
_51 = it_10 + _50;
c2.D.31774._M_impl.D.31086._M_finish = -4B;
MEM[(int *)0B + -4B] ={v} {CLOBBER(eob)};


so the only controlling condition is that on it_10 which we should figure
is 0B.  But of course we can't know this given we don't inline
std::__find_if.isra here.  There's nothing to fix here IMO, the only
missed optimization is that we don't isolate this path and reduce
the if (it_10 != 0B) case to a trap() - but we should arguably diagnose
such cases still.

A library fix is OK and it causes us to inline __find_if and avoid
the diagnostic.

Reply via email to