title: Why does the C++ linker allow undefined functions?
body: <p>This C++ code, perhaps surprisingly, prints out <code>1</code>. </p>
  
  <pre><code>#include &lt;iostream&gt;
  
  std::string x();
  
  int main() {
  
      std::cout &lt;&lt; "x: " &lt;&lt; x &lt;&lt; std::endl;
      return 0;
  }
  </code></pre>
  
  <p><code>x</code> is a function prototype, which seems to be viewed as a function pointer, and C++ Standard section 4.12 Boolean conversions says:</p>
  
  <blockquote>
    <p>4.12 Boolean conversions [conv.bool] 1 A prvalue of arithmetic, unscoped enumeration, pointer, or pointer to member type can be
    converted to a prvalue of type bool. A zero value, null pointer value,
    or null member pointer value is converted to false; any other value is
    converted to true. For direct-initialization (8.5), a prvalue of type
    std::nullptr_t can be converted to a prvalue of type bool; the
    resulting value is false.</p>
  </blockquote>
  
  <p>However, <code>x</code> is never bound to a function. As I would expect, the C linker doesn't allow this. However in C++ this isn't a problem at all. Can anyone explain this behavior?</p>