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

    <tr>
        <th>Summary</th>
        <td>
            No matching operator new when instanciating a template method using unordered_map from another module
        </td>
    </tr>

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

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

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

<pre>
    When trying to migrate my application to C++ modules using clang-15 on ubuntu 22.04, I encounter errors with template resolution.
Maybe be this is linked to https://github.com/llvm/llvm-project/issues/56916 but the last comment says it all about grammar sugar.

Please find below a minimal error case to reproduce my problem.

First, a module defines a template method using an unordered_map:
```c++
module;
#include <unordered_map>
export module test;
export namespace test
{
    struct S
    {
 std::unordered_map<int,int> map;
        template <typename T> void d()
        {
            map.try_emplace(0, 0);
        }
 };
}
```
Then, a second one calls it:
```
export module test2;
import test;
export namespace test
{
    void f(S & s)
 {
        s.d<int>();
    }
}
```
When compiling the second module, I got errors:
```console
$ clang++-15 --precompile test.cppm -o test.pcm -std=c++20 -fprebuilt-module-path=. -Wall -I.
$ clang++-15 --precompile test2.cppm -o test2.pcm -std=c++20 -fprebuilt-module-path=. -Wall -I.
In module 'test' imported from test2.cppm:2:
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/hashtable_policy.h:1965:6: error: no matching 'operator new' function for non-allocating placement new expression; include <new>
            ::new ((void*)__n) __node_type;
 ^~
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/hashtable.h:306:19: note: in instantiation of function template specialization 'std::__detail::_Hashtable_alloc<std::allocator<std::__detail::_Hash_node<std::pair<const int, int>, false>>>::_M_allocate_node<const std::piecewise_construct_t &, std::tuple<int &&>, std::tuple<int &&>>' requested here
 _M_node(__h->_M_allocate_node(std::forward<_Args>(__args)...))
 ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/hashtable_policy.h:912:39: note: in instantiation of function template specialization 'std::_Hashtable<int, std::pair<const int, int>, std::allocator<std::pair<const int, int>>, std::__detail::_Select1st, std::equal_to<int>, std::hash<int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true>>::_Scoped_node::_Scoped_node<const std::piecewise_construct_t &, std::tuple<int &&>, std::tuple<int &&>>' requested here
          typename __hashtable::_Scoped_node __node {
 ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/unordered_map.h:481:16: note: in instantiation of function template specialization 'std::__detail::_Insert_base<int, std::pair<const int, int>, std::allocator<std::pair<const int, int>>, std::__detail::_Select1st, std::equal_to<int>, std::hash<int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true>>::try_emplace<int, int>' requested here
          return _M_h.try_emplace(cend(), std::move(__k),
 ^
/home/etham/test_modules/test.cppm:14:17: note: in instantiation of function template specialization 'std::unordered_map<int, int>::try_emplace<int>' requested here
            map.try_emplace(0, 0);
                ^
test2.cppm:7:11: note: in instantiation of function template specialization 'test::S::d<int>' requested here
 s.d<int>();
          ^
In module 'test' imported from test2.cppm:2:
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/alloc_traits.h:518:4: error: no matching function for call to 'construct_at'
 std::construct_at(__p, std::forward<_Args>(__args)...);
 ^~~~~~~~~~~~~~~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/hashtable_policy.h:1966:27: note: in instantiation of function template specialization 'std::allocator_traits<std::allocator<std::__detail::_Hash_node<std::pair<const int, int>, false>>>::construct<std::pair<const int, int>, const std::piecewise_construct_t &, std::tuple<int &&>, std::tuple<int &&>>' requested here
 __node_alloc_traits::construct(_M_node_allocator(),
 ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/hashtable.h:306:19: note: in instantiation of function template specialization 'std::__detail::_Hashtable_alloc<std::allocator<std::__detail::_Hash_node<std::pair<const int, int>, false>>>::_M_allocate_node<const std::piecewise_construct_t &, std::tuple<int &&>, std::tuple<int &&>>' requested here
 _M_node(__h->_M_allocate_node(std::forward<_Args>(__args)...))
 ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/hashtable_policy.h:912:39: note: in instantiation of function template specialization 'std::_Hashtable<int, std::pair<const int, int>, std::allocator<std::pair<const int, int>>, std::__detail::_Select1st, std::equal_to<int>, std::hash<int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true>>::_Scoped_node::_Scoped_node<const std::piecewise_construct_t &, std::tuple<int &&>, std::tuple<int &&>>' requested here
          typename __hashtable::_Scoped_node __node {
 ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/unordered_map.h:481:16: note: in instantiation of function template specialization 'std::__detail::_Insert_base<int, std::pair<const int, int>, std::allocator<std::pair<const int, int>>, std::__detail::_Select1st, std::equal_to<int>, std::hash<int>, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Prime_rehash_policy, std::__detail::_Hashtable_traits<false, false, true>>::try_emplace<int, int>' requested here
          return _M_h.try_emplace(cend(), std::move(__k),
 ^
/home/etham/test_modules/test.cppm:14:17: note: in instantiation of function template specialization 'std::unordered_map<int, int>::try_emplace<int>' requested here
            map.try_emplace(0, 0);
                ^
test2.cppm:7:11: note: in instantiation of function template specialization 'test::S::d<int>' requested here
 s.d<int>();
 ^
/usr/bin/../lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/bits/stl_construct.h:94:5: note: candidate template ignored: substitution failure [with _Tp = std::pair<const int, int>, _Args = <const std::piecewise_construct_t &, std::tuple<int &&>, std::tuple<int &&>>]: no matching 'operator new' function for non-allocating placement new expression; include <new>
 construct_at(_Tp* __location, _Args&&... __args)
    ^
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWs1u4zgSfhr6UrBhUZZtHXxInBjbh14MkAbmKFBS2eIORWpIqtPZwz77okRJ_ukknd3pRTI7FgxZEotF8quqr1i2hHPyoBE3LLllyd1EtL4yduMqoQ-mxUluyqfNrxVq8PZJ6gN4A7U8WOER6icQTaNkIbw0mlq2jN8yfgu1KVuFDlpHXQol9GEaJWA0tHmrfQucz-YLxrfwCVAXptUeLaC1xjp4lL4Cj3WjaBCLzqiWBpix-R2b33wWTzlCjuAr6UA6UFL_hiUNX3nfOBbfML5jfHeQvmrzWWFqxndKfR2-po01_8DCM76TzrXoGN8lyzRaQt568BWCEs5DYeoatQcnnhxID0IpELlpPRysqGthwbUHYftZhfMvCoVD2EtdQo7KPIKAWmpZCxVWBwW1ewMWG2vKtuhQbKzJFdZnqnbSOk8IiR5NKHEvNToQR3Bq9JUpe5iFhlYbW6LFMqtFQ0AEhct5-BTBPOFp0Mri_pbxWOpCtSUCi7cXiu6DDH5rjPXDfDw6P3bvm7So0TWi6FuD5lUvAwDgvG0LDw_HJ8dm50uac3xzMfpWakKCzvE9dI9ONNIxAsLirX9qkKYBX0j6q5EllIyvGU_P-5xNazhq0cy8fco6fQUyvp6TDebU-3JQtrrrH9DViOPwdEQ93H6pUAdzOiyMLsFohEIoRc71valeApyPA8m6a_uvrNChsmd8_QCML8EdwfkOFTcrewvE9z2Mp0Acl_vCujvuKEzdSNXRR4UDAL0DdiRwML4P_2e81mhnFA5uugh8ElyZWGU6bSyGEcKCZ0XT1DA14aYpaph2rnXX-z-fw3TfWMxbqfw0TGPaCF-x-G4G018p0qefZm8fkJ-NyP_okJ_0YHHGV50F-QqCubGEvTX1yagsvuFHzPiudZbxXS4147vZjChP5kSGRcH47tt6mS0XUyV1-2160C3ju4gPghenng0Y3w200Qvn0hNlVsJ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