title: Why construction of std::unique_ptr for incomplete type compiles?
body: <p>Code:</p>
  
  <pre><code>#include &lt;memory&gt;
  
  struct Data;
  std::unique_ptr&lt;Data&gt; make_me();
  
  int main()
  {
      std::unique_ptr&lt;Data&gt; m = make_me();
      return 0;
  }
  </code></pre>
  
  <p>Which of course fails:</p>
  
  <pre><code>In file included from &lt;source&gt;:1:
  In file included from /opt/compiler-explorer/gcc-7.1.0/lib/gcc/x86_64-linux-gnu/7.1.0/../../../../include/c++/7.1.0/memory:80:
  /opt/compiler-explorer/gcc-7.1.0/include/c++/7.1.0/bits/unique_ptr.h:76:16: error: invalid application of 'sizeof' to an incomplete type 'Data'
          static_assert(sizeof(_Tp)&gt;0,
                        ^~~~~~~~~~~
  /opt/compiler-explorer/gcc-7.1.0/include/c++/7.1.0/bits/unique_ptr.h:268:4: note: in instantiation of member function 'std::default_delete&lt;Data&gt;::operator()' requested here
            get_deleter()(__ptr);
            ^
  8 : &lt;source&gt;:8:31: note: in instantiation of member function 'std::unique_ptr&lt;Data, std::default_delete&lt;Data&gt; &gt;::~unique_ptr' requested here
      std::unique_ptr&lt;Data&gt; m = make_me();
                                ^
  3 : &lt;source&gt;:3:8: note: forward declaration of 'Data'
  struct Data;
         ^
  1 error generated.
  Compiler returned: 1
  </code></pre>
  
  <p>But adding below line at the end of above code compiles fine:</p>
  
  <pre><code>struct Data {};
  </code></pre>
  
  <p>My question is why this code compiles and works when Data is declared after point of instantiation of std::unique_ptr? Seemingly, both cases should fail with the same/similar error..</p>
  
  <p>Whole example on godbolt: <a href="https://godbolt.org/g/FQqxwN" rel="nofollow noreferrer">https://godbolt.org/g/FQqxwN</a></p>