title: What is the behavior when there are mismatched types between an extern declaration and the definition?
body: <p>Suppose I have two files:</p>
  
  <p>==File1==</p>
  
  <pre><code>extern char* foo;
  </code></pre>
  
  <p>==File2==</p>
  
  <pre><code>double foo;
  </code></pre>
  
  <p>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.</p>
  
  <p>My questions are:</p>
  
  <ul>
  <li>Does this result in undefined behavior according to the c++ standard? If not what goes in <em>foo</em> in File1?</li>
  <li>Could linkers catch this kind of type mismatch?</li>
  </ul>