https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65752
--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> --- Other testcase: int main() { int *p; int x = 0; if (p == &x) *p = 1; return x; } we optimize this to return 0. You probably wouldn't consider that invalid I guess?