[Bug tree-optimization/65752] Too strong optimizations int -> pointer casts
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Apr 17 09:23:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65752
--- Comment #58 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #49)
> Related testcase from PR61502:
>
> #include <stdio.h>
>
> int main()
> {
> int x, y = 1;
> int *volatile v;
> int *p;
>
> v = &y;
> p = v;
> if (p == &x + 1) {
> *p = 2;
> printf("y = %d\n", y);
> }
> }
>
> which shows how propagating conditional equivalences (&x+1 into *p = 2)
> breaks
> alias analysis.
We now optimize the comparison to false via ptrs_compare_unequal given
&x + 1 has provenance &x and p has provenance &y. Thus we decided to
ignore that sub-sentence of the standard that seems to allow comparing
such pointers. So we behave as-if we'd put at least one byte of padding
after each object.
More information about the Gcc-bugs
mailing list