Is there any guarantees that the functions which differs only by its names (not parameters and return type also) can’t share the same address in C and C++? I don’t see anything about it in the standard.
#include <cassert>
void foo() {}
void bar() {}
int main()
{
assert(foo != bar);
}
The C++11 standard says
If you don’t have any pointers to the functions, they just might have the same address, but we wouldn’t know. If you are comparing pointers to two different functions, they must not compare equal.
One cause for confusion might be that the MSVC compilers are known to combine code for template functions that happen to produce identical machine code for different types (like
intandlong). This is not compliant.However, this is for functions with different signatures, and not exactly what this question is about.