https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111773
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|ASSIGNED |UNCONFIRMED Ever confirmed|1 |0 Assignee|rguenth at gcc dot gnu.org |unassigned at gcc dot gnu.org --- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> --- So the second example is fixed, but it's quite a corner-case so probably not worth backporting. Given we have a single bugreport for two issues back to UNCONFIRMED for the first issue. I agree with Andrew _that_ issue behaves within the constraints of the standard. ISTR it says that 'operator new' has to return a pointer that nothing else points to which means it acts as if it were restrict qualified. That allows GCC to conclude x != 0 because it rewrites x == 0 as a - p == 0 and a == p. The difference operation cannot be constant folded based on this but during IPA optimization we inline 'new' which exposes p == a and thus a - p == 0.