https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85315
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |msebor at gcc dot gnu.org --- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> --- A simpler test case that shows the same optimization opportunity is: int f (int i) { extern int x; int y; return &y + i == &x; } A test case that both Clang and GCC get wrong is below. (This will be discussed at the next WG14 meeting -- see http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2222.htm#q23-can-one-do-comparison-between-pointers-to-objects-of-compatible-types-with-different-provenances-that-are-not-strictly-within-their-original-allocations) int g (int i) { int x, y, z; int *p = &x + i; int *q = &y; return p == q; }