It appears that separate function definitions that use a qualified name (including but not limited to out-of-line member function definitions) do not properly check that the return type of the defined function matches the return type present on the declaration of the same signature.
Interestingly, a definition using an unqualified name does appear to check correctly, so I'm inclined to think the problem has to do with the name being qualified in the definition rather than the specific case of an out-of-line member function definition.
#include <iostream>
#include <string>
using namespace std;
void foo();
void bar();
int foo() {
return 3;
}
int ::bar() {
return 3;
}
class Test {
public:
void blah();
string bleh();
};
int Test::blah() {
return 3;
}
const char * Test::bleh() {
return "test";
}
int main() {
cout << "Hello World!" << endl;
}
It appears that separate function definitions that use a qualified name (including but not limited to out-of-line member function definitions) do not properly check that the return type of the defined function matches the return type present on the declaration of the same signature.
Interestingly, a definition using an unqualified name does appear to check correctly, so I'm inclined to think the problem has to do with the name being qualified in the definition rather than the specific case of an out-of-line member function definition.