title: Is passing a C++ object into its own constructor legal?
body: <p>I am surprised to accidentally discover that the following works:</p>
  
  <pre><code>#include &lt;iostream&gt;            
  int main(int argc, char** argv)
  {
    struct Foo {
      Foo(Foo&amp; bar) {
        std::cout &lt;&lt; &amp;bar &lt;&lt; std::endl;
      }
    };
    Foo foo(foo); // I can't believe this works...
    std::cout &lt;&lt; &amp;foo &lt;&lt; std::endl; // but it does...
  }
  </code></pre>
  
  <p>I am passing the address of the constructed object into its own constructor. This looks like a circular definition at the source level. Do the standards really allow you to pass an object into a function before the object is even constructed or is this undefined behavior? </p>
  
  <p>I suppose it's not that odd given that all class member functions already have a pointer to the data for their class instance as an implicit parameter. And the layout of the data members is fixed at compile time.</p>
  
  <p>Note, I'm NOT asking if this is useful or a good idea; I'm just tinkering around to learn more about classes.</p>