4 ms·
Did you miss the part where two pointers with identical bit patterns can compare not equal? E.g. in recent versions of gcc #include <stdio.h> int main
by TheCoelacanth 11y ago
Did you miss the part where two pointers with identical bit patterns can compare not equal? E.g. in recent versions of gcc
#include <stdio.h>
int main(void)
{
int x, y;
int *p = &x + 1;
int *q = &y;
printf("%p %p %d\n", p, q, p == q);
return 0;
}
prints
0x7f7fffffdafc 0x7f7fffffdafc 0
- deleted 11y ago[deleted]
- botw 11y agoThis is interesting. If this is true, then a lot of code based on the assumption p == q would be broken.