<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Default parameter of unique_ptr instantiates causing failure with incomplete type:"
   href="https://bugs.llvm.org/show_bug.cgi?id=42303">42303</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Default parameter of unique_ptr instantiates causing failure with incomplete type:
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>C++
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>erich.keane@intel.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>#include <memory>
struct Base;
  class Class {
       Class ( std::unique_ptr<Base>&& combat_targets = nullptr);
   };


The above reproducer results in:
bash-4.2$ ../../llvm-project/build/bin/clang++ --version
clang version 9.0.0 (/iusers/ekeane1/workspaces/llvm-project/clang
689509edab4d073ec3bca7d433808ae48a6cddd8)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir:
/export/iusers/ekeane1/workspaces/xmain/repro/../../llvm-project/build/bin

bash-4.2$ ../../llvm-project/build/bin/clang++ test.cpp
In file included from test.icx.cpp:1:
In file included from
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/memory:81:
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/bits/unique_ptr.h:65:16:
error: invalid application of 'sizeof' to an incomplete type 'Base'
        static_assert(sizeof(_Tp)>0,
                      ^~~~~~~~~~~
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/bits/unique_ptr.h:184:4:
note: in instantiation of member function
'std::default_delete<Base>::operator()' requested here
          get_deleter()(__ptr);
          ^
/usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../../include/c++/4.8.5/bits/unique_ptr.h:157:50:
note: in instantiation of member function 'std::unique_ptr<Base,
std::default_delete<Base> >::~unique_ptr' requested here
      constexpr unique_ptr(nullptr_t) noexcept : unique_ptr() { }
                                                 ^
test.icx.cpp:3:12: note: forward declaration of 'Base'


This appears to be a regression, as current godbolt (r363523) doesn't seem to
repro the issue. <a href="https://godbolt.org/z/Z_2tlY">https://godbolt.org/z/Z_2tlY</a>

We seem to be instantiating the default parameter before the function is used,
so this no longer works (it does in GCC as well).  Is this intentional?</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>