https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91227
--- Comment #5 from rguenther at suse dot de <rguenther at suse dot de> --- On Tue, 23 Jul 2019, msebor at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91227 > > --- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> --- > The results of relational expressions (<, >, <=, and <=) involving pointers to > unrelated objects are undefined and unspecified in C and C++, respectively. > (See 6.5.8, p5 in C 11 and [expr.rel], p3 in C++ 17). Does "unspecified" allow p > q != !(p <= q)? I think so (it's not implementation defined). Still for GCC we need to find something sensible for QoI reasons. Eventually inserting a __builtin_trap () before a condition data dependent on such comparison is better than folding it to an essentially random constant (at least I don't see how we could easily get consistency here). So this might be something for path isolation, not so much for constant folding? Similar things could be done for uninitialized values participating in a controlling condition.