title: Inline constructors and One Definition Rule
body: <p>Consider following source files
  1.cpp</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  struct X
  {
      X()
      {
          cout &lt;&lt; "1" &lt;&lt; endl;
      }
  };
  
  void bar();
  
  void foo()
  {
      X x;
  }
  
  int main()
  {
      foo();
      bar();
      return 0;
  }
  </code></pre>
  
  <p>2.cpp</p>
  
  <pre><code>#include &lt;cstdio&gt;
  
  struct X
  {
      X()
      {
          printf("2\n");
      }
  };
  
  void bar()
  {
      X x;
  }
  </code></pre>
  
  <p>Is program compiled from these files well-formed? What should be in it's output?</p>
  
  <p>I've expected linker error due to violation of One Definition Rule or output "1 2". However it prints out "1 1" when compiled with g++ 3.4 and VC 8.0.<br>
  How this can be explained?</p>