title: Why doesn't this "undefined extern variable" result in a linker error in C++17?
body: <p>I have compiled and ran the following program in a C++17 compiler (Coliru). In the program, I <strong>declared</strong> an <code>extern</code> variable, but <strong>did not define</strong> it. However, the compiler doesn't give a <strong>linker error</strong>.</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  extern int i; // Only declaration
  
  int func() 
  {
      if constexpr (true)
          return 0;
      else if (i)
          return i;
      else
          return -1;
  }
  
  int main() 
  {
      int ret = func();
      std::cout&lt;&lt;"Ret : "&lt;&lt;ret&lt;&lt;std::endl;
  }
  </code></pre>
  
  <p><strong>Why doesn't the compiler give a linker error?</strong></p>