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

            Bug ID: 119831
           Summary: Missed pointer compare folding
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: rguenth at gcc dot gnu.org
  Target Milestone: ---

We fail to simplify sth like

_Bool foo (char *p, unsigned long o)
{
  if (&p + o > &p)
    return 0;
  return 1;
}

this is folded early to

  if ((ssizetype) (o * 8) > 0)

but it could fold to o != 0 or o == 1 since &p + o is UB when not in [0, 1].
Possibly the existing folding preempts such other existing folding (if it
exists).

Reply via email to