https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65752
--- Comment #39 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Alexander Cherepanov from comment #38) > IMHO this bug is not specific to integers and boils down to this: when a > check for equality ignores provenance for some reason, phiopt nevertheless > will replace one variable by another with the wrong provenance. > > Integers are surely compared without regard to prevenance. That's one case. > Another case is a comparison of two pointers when one of the lost its > provenance info. E.g. the program (somewhat based on pr61502): > > #include <stdint.h> > #include <stdio.h> > > int main() > { > int y, x = 0; > int *volatile v = &x; > int *xp = v; > int *i = &y + 1; > > if (xp != i) { > printf("hello\n"); > xp = i; > } > > *xp = 15; > > printf("%d\n", x); > } > > prints 0 for me with gcc 5.2.0 -O2. Except the above testcase is invalid/undefined as &y + 1 is undefined if deferenced and &x and &y + 1 cannot be compared in a defined sense as both deals with two different arrays.