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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|FIXED                       |INVALID

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Peter Bisroev from comment #5)
> So my question is, is gcc allowed to assume that the target will always
> match?

Yes. If p is not null then it points to a value object. It is undefined to
decrement a pointer "before" the start of an object (you can only increment to
one position past the end). That means the compiler can assume that a non-null
pointer never becomes null, because it would have to point before the start of
the object to do so. So if it can't become null, the !p check is always false,
and it must return true.

Reply via email to