int a[20], b[20], *p = a, i; if ((uintptr_t)(a + 20) == (uintptr_t)b) { b[5] = 1; for (i = 0; i < 40; i++) *p++ = 0; printf("%d\n", b[5]); }
-
-
Replying to @ch3root
gcc 4.9 and 5.2 with -O2 print 1 while the right result is 0. How much black magic do you need, to explain that the code is invalid C?
4 replies 0 retweets 0 likes -
Replying to @RichFelker
@RichFelker Isn't interchangability of equal values is one of the fundamentals of C?2 replies 0 retweets 0 likes -
Replying to @RichFelker
@RichFelker Ok. C11, 6.3.2.3p1, says that (int *)(void *)p is equal to p (given "int *p;"). Can it be used instead of p?1 reply 0 retweets 0 likes -
Replying to @ch3root
@ch3root@RichFelker Address equality is orthogonal to the memory rules. Can't access an object via a pointer derived from another.1 reply 0 retweets 0 likes -
Replying to @CopperheadOS
@ch3root@RichFelker A pointer in C isn't simply an address. It's also undefined to do accesses via an integer-derived pointer.1 reply 0 retweets 0 likes
@CopperheadSec @ch3root Not if the value of that integer is equal to the value obtained by casting a valid pointer to uintptr_t.
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.