What is the behavior when there are mismatched types between an extern declaration and the definition?
Suppose I have two files: ==File1== extern char* foo; ==File2== double foo; These two files seem to compile and link just fine with both g++ and clang++ despite the type mismatch. As I understand it the recommended practice is to put the extern declaration in a header which both files include so File2 will throw a redefinition error. My questions are: Does this result in undefined behavior according to the c++ standard? If not what goes in foo in File1? Could linkers catch this kind of type mismatch? Does this result in undefined behavior according to the c++ standard? Well, the real question