The C++ standard says the following about the equality operator ==
:
[C++11: 5.10/1]:
[..] Two pointers of the same type compare equal if and only if they are both null, both point to the same function, or both represent the same address.
My initial interpretation was that functions don't semantically have "addresses" per se at this level, and that therefore the "or both represent the same address" could only be intended to refer to objects, and not functions. Otherwise why bother with the "point to the same function" clause?
That is, two function pointers of the same type compare equal if and only if both point to the same function, period.
The consequence of this would be that the behaviour witnessed in this question (pointers to two distinct but identical functions have identical values) would be an implementation bug, since pointers to distinct functions would be required to be unique.
I feel that this is the intent of the clause, but I can't find a way to objectively defend the viewpoint that this is how the passage's meaning should actually be inferred, or that it really was the intent of the committee, and now my interpretation has come into question:
[D]iscuss with me how "[...] or both represent the same address." is not being satisfied by Visual C++'s behavior. (@jstine)
So my question is about the intent of this standard passage.
Either:
I am on the right track: function pointers must compare equal iff they both point to the same function ("addresses" be damned), or
There is a redundancy in the passage: function pointers must compare equal iff they both point to the same function or both represent the same address; and, by extension, an implementation is allowed to make two functions exist at the same address.
Which is it?