by crehn · 8y ago · 0 comments
Can someone explain to me the rationale behind this? Why not just "two pointers compare equal if they point to the same address"?
The standard was also written to allow for C interpreters, where you may not have an underlying linear memory model at all and all pointers are represented internally in some complex way (for example 'object ID + offset inside object'). Here you don't have any particular idea of 'an address' as a distinct thing and so you can't naturally compare two pointers to different objects in any meaningful way.
float my_bad_function(void) { int x = 5; float* y = (float) &x; return y; }