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]); }
@ch3root Are you sure? I think the code has UB. Does p1==p2 evaluating true imply they are the same/interchangeable?
-
-
@RichFelker Isn't interchangability of equal values is one of the fundamentals of C? -
@ch3root It's not specified anywhere and not true for IEEE floats. -
@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? -
@ch3root@RichFelker Address equality is orthogonal to the memory rules. Can't access an object via a pointer derived from another. -
@ch3root@RichFelker A pointer in C isn't simply an address. It's also undefined to do accesses via an integer-derived pointer. -
@CopperheadSec@ch3root Not if the value of that integer is equal to the value obtained by casting a valid pointer to uintptr_t.
End of conversation
New conversation -
-
-
@ch3root If this were valid C, then using A[1][0] to access A[0][1] in T A[2][2] should also be valid, no? But latter is ex. in Annex J. -
@RichFelker That's a bit different and seemingly violates C11, 6.5.6p8. Worth revisiting later. -
@RichFelker Ok, first question: are a[0][2] and a[1][2] valid given unsigned char a[3][3]? -
@ch3root I probably confused this issue too much already with mistyped (on Android kb) tweets; let's continue it elsewhere. - End of conversation
New conversation -
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.