<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/57561>57561</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Linker failure in std::make_shared: ~__shared_ptr_emplace / ~_Sp_counted_ptr_inplace
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          ecatmur
      </td>
    </tr>
</table>

<pre>
    ```c++
#include <memory>
#include <type_traits>
struct G { auto operator()(auto f) { return f(0); } };
int main() {
    auto f = [](auto) -> void { std::make_shared<int>(); };
    static_assert(std::is_invocable_v<G, decltype(f)>);
    f(0);
}
```
fails linking with undefined reference to (libc++):
```
(.rodata._ZTVNSt3__120__shared_ptr_emplaceIiNS_9allocatorIiEEEE[_ZTVNSt3__120__shared_ptr_emplaceIiNS_9allocatorIiEEEE]+0x10): undefined reference to `std::__1::__shared_ptr_emplace<int, std::__1::allocator<int> >::~__shared_ptr_emplace()'
(.rodata._ZTVNSt3__120__shared_ptr_emplaceIiNS_9allocatorIiEEEE[_ZTVNSt3__120__shared_ptr_emplaceIiNS_9allocatorIiEEEE]+0x18): undefined reference to `std::__1::__shared_ptr_emplace<int, std::__1::allocator<int> >::~__shared_ptr_emplace()'
(.rodata._ZTVNSt3__120__shared_ptr_emplaceIiNS_9allocatorIiEEEE[_ZTVNSt3__120__shared_ptr_emplaceIiNS_9allocatorIiEEEE]+0x20): undefined reference to `std::__1::__shared_ptr_emplace<int, std::__1::allocator<int> >::__on_zero_shared()'
(.rodata._ZTVNSt3__120__shared_ptr_emplaceIiNS_9allocatorIiEEEE[_ZTVNSt3__120__shared_ptr_emplaceIiNS_9allocatorIiEEEE]+0x30): undefined reference to `std::__1::__shared_ptr_emplace<int, std::__1::allocator<int> >::__on_zero_shared_weak()'
```
or (libstdc++):
```
(.rodata._ZTVSt23_Sp_counted_ptr_inplaceIiSaIiELN9__gnu_cxx12_Lock_policyE2EE[_ZTVSt23_Sp_counted_ptr_inplaceIiSaIiELN9__gnu_cxx12_Lock_policyE2EE]+0x10): undefined reference to `std::_Sp_counted_ptr_inplace<int, std::allocator<int>, (__gnu_cxx::_Lock_policy)2>::~_Sp_counted_ptr_inplace()'
(.rodata._ZTVSt23_Sp_counted_ptr_inplaceIiSaIiELN9__gnu_cxx12_Lock_policyE2EE[_ZTVSt23_Sp_counted_ptr_inplaceIiSaIiELN9__gnu_cxx12_Lock_policyE2EE]+0x18): undefined reference to `std::_Sp_counted_ptr_inplace<int, std::allocator<int>, (__gnu_cxx::_Lock_policy)2>::~_Sp_counted_ptr_inplace()'
(.rodata._ZTVSt23_Sp_counted_ptr_inplaceIiSaIiELN9__gnu_cxx12_Lock_policyE2EE[_ZTVSt23_Sp_counted_ptr_inplaceIiSaIiELN9__gnu_cxx12_Lock_policyE2EE]+0x20): undefined reference to `std::_Sp_counted_ptr_inplace<int, std::allocator<int>, (__gnu_cxx::_Lock_policy)2>::_M_dispose()'
(.rodata._ZTVSt23_Sp_counted_ptr_inplaceIiSaIiELN9__gnu_cxx12_Lock_policyE2EE[_ZTVSt23_Sp_counted_ptr_inplaceIiSaIiELN9__gnu_cxx12_Lock_policyE2EE]+0x28): undefined reference to `std::_Sp_counted_ptr_inplace<int, std::allocator<int>, (__gnu_cxx::_Lock_policy)2>::_M_destroy()'
(.rodata._ZTVSt23_Sp_counted_ptr_inplaceIiSaIiELN9__gnu_cxx12_Lock_policyE2EE[_ZTVSt23_Sp_counted_ptr_inplaceIiSaIiELN9__gnu_cxx12_Lock_policyE2EE]+0x30): undefined reference to `std::_Sp_counted_ptr_inplace<int, std::allocator<int>, (__gnu_cxx::_Lock_policy)2>::_M_get_deleter(std::type_info const&)'
```

I guess all the unevaluated-context stuff inside `__invokable_r` (or libstdc++ equivalent) is persuading Sema that the class template instantiation vtable member emission stuff has already been done.
</pre>
<img width="1px" height="1px" alt=""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