[Bug tree-optimization/82282] PRE cannot blindly fold integer-to-pointer/pointer-to-integer round-trips
rguenther at suse dot de
gcc-bugzilla@gcc.gnu.org
Fri Sep 22 11:26:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82282
--- Comment #5 from rguenther at suse dot de <rguenther at suse dot de> ---
On Fri, 22 Sep 2017, nunoplopes at sapo dot pt wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82282
>
> --- Comment #4 from Nuno Lopes <nunoplopes at sapo dot pt> ---
> There are two major transformations going on:
> if (u != v) {
> v = u;
> }
> =>
> v = u
>
> (with v, u integers)
>
> and:
>
> glb = (int*)(uinptr_t)foo)
> =>
> glb = foo
>
>
> Doing both triggers the end-to-end miscompilation for a C program that exhibits
> no UB. That means that one of transformations is wrong.
> Disabling integer propagation would be really weird and bad.
> So we are left with making "(int*)(uinptr_t)foo -> foo" an invalid
> transformation in general. It's correct in some cases, but not always.
The C standard says it is correct as in, it yields the same pointer.
More information about the Gcc-bugs
mailing list