https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65752

--- Comment #18 from rguenther at suse dot de <rguenther at suse dot de> ---
On Tue, 19 May 2015, gil.hur at sf dot snu.ac.kr wrote:

> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65752
> 
> --- Comment #17 from Chung-Kil Hur <gil.hur at sf dot snu.ac.kr> ---
> Hi Richard,
> 
> I modified the example further.
> 
> #include <stdio.h>
> 
> int main() {
>   int x = 0;
>   uintptr_t xp = (uintptr_t) &x;
>   uintptr_t i, j;
> 
>   for (i = 0; i < xp; i++) { }
>   j = i;
>   /* The following "if" statement is never executed because j == xp */
>   if (j != xp) { 
>     printf("hello\n");
>     j = xp; 
>   }

Here j is always xp and thus ...

>   *(int*)((xp+i)-j) = 15;

... this can (and is) simplified to *(int *)i = 15; making it the same
testcase again.

>   printf("%d\n", x);
> }
> 
> The above example does not print "hello", so i can assume that "j = xp" is not
> executed.
> However, the program prints "0" instead of "15".
> Can you explain this?

Reply via email to