This question is a follow-up question of this one.
Consider the following program:
#include <cmath>
// meaningless, only for language-lawyer purpose
void abs(void*) {}
int main(){
abs(nullptr);
}
Does this program result in undefined behavior?
The related part in the standard is [extern.names]/4:
Each function signature from the C standard library declared with external linkage is reserved to the implementation for use as a function signature with both extern "C" and extern "C++" linkage, or as a name of namespace scope in the global namespace.
I'm not sure whether overloading is permitted.
There are two parts to this statement, as it talks about names (from the C standard) that are reserved (for C++ implementations). In particular,
This includes the C library function
abs
So the name
::abs
is reserved for the C++ implementation. You can't use it. Overloading is irrelevant.tl;dr - yes, you can
http://www.eel.is/c++draft/reserved.names#extern.names
Pulling in the rest of the context:
And then also
These suggest you can, as it is only the signature that is reserved.
Bonus for namespace ::std
http://www.eel.is/c++draft/library#namespace.std
http://en.cppreference.com/w/cpp/language/extending_std has summarised the exceptions