This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/82282] PRE cannot blindly fold integer-to-pointer/pointer-to-integer round-trips


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]