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

    <tr>
        <th>Summary</th>
        <td>
            `std::construct_at` in one module requires `#include <new>` in 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>
          davidstone
      </td>
    </tr>
</table>

<pre>
    The following valid set of modules

```
// a.cpp
module;

#include <memory>

export module a;

export template<typename T>
void f(T * ptr) {
        std::construct_at(ptr);
}
```

```
// b.cpp
export module b;
import a;

struct s {};

void g() {
        auto x = s();
        f(&x);
}
```

causes clang to fail with

```
a.cpp:10:2: error: no matching function for call to 'construct_at'
        std::construct_at(ptr);
 ^~~~~~~~~~~~~~~~~
b.cpp:9:2: note: in instantiation of function template specialization 'f<s>' requested here
        f(&x);
 ^
/usr/lib64/gcc/x86_64-pc-linux-gnu/12.2.0/../../../../include/c++/12.2.0/bits/stl_construct.h:94:5: note: candidate template ignored: substitution failure [with _Tp = s, _Args = <>]: no matching 'operator new' function for non-allocating placement new expression; include <new>
    construct_at(_Tp* __location, _Args&&... __args)
    ^
1 error generated.
```

The error is resolved if `b.cpp` includes `<new>`, despite module `b` theoretically knowing nothing about module `a` happening to call `std::construct_at` with one of its types.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVd1yqzgMfhrlRhPGMQHKBRdpc_IEvc8YI8C7xmZtk6Z7sc--Y8hPk9PpHIYhwZbE90n6ZOG96gxRBdkrZPuVmEJvXdWIk2p8sIZWtW0-q_eesLVa2w9lOjwJrRr0FNC2ONhm0uSB7YHtLs-cXe7llR-AH1AkchyXlcUH0tcHL54qI_XUEEL6NtBg3Sekv76a0Hm0Llw-ieIpwGU30DBqEQjSt_A5khED4fst0MmqBlvgL-8IfIdjcMBLhOIWqfShgXQH6U5a44ObZD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