Pointers of several functions

c, c++

Solution

The C++11 standard says

5.10 Equality operators Pointers of the same type (after pointer conversions) can be compared for equality. 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 (3.9.2).

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 `int` and `long`). This is not compliant.

However, this is for functions with different signatures, and not exactly what this question is about.

Problem

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); } ```

Original source