For two pointers a
and b
that both point to the same object or function, under which circumstances do the C standards guarantee that a == b
? Are there any platforms on which a != b
could hold when a
and b
point to the same object?
According to the C Standard (6.5.9 Equality operators from N1548 Committee Draft — December 2, 2010 ISO/IEC 9899:201x)
6 Two pointers compare equal if and only if both are null pointers, both are pointers to the same object (including a pointer to an object and a subobject at its beginning) or function, both are pointers to one past the last element of the same array object, or one is a pointer to one past the end of one array object and the other is a pointer to the start of a different array object that happens to immediately follow the first array object in the address space.109)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With