<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/90620>90620</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[C++20] [Modules] Cannot export type_info/operator new/operator delete
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
huangqinjin
</td>
</tr>
</table>
<pre>
#### `test.cppm`
```c++
module;
#include <stddef.h>
export module test;
extern "C++"
{
export class type_info; // 0
export void* operator new(size_t); // 1
export void* operator new[](size_t); // 2
export void operator delete(void*) noexcept; // 3
export void operator delete[](void*) noexcept; // 4
export void operator delete(void*, size_t) noexcept; // 5
export void operator delete[](void*, size_t) noexcept; // 6
}
```
#### targeting x86_64-linux-gnu
```shell
✗ clang --target=x86_64-linux-gnu -std=c++20 --precompile test.cppm
test.cppm:11:18: error: cannot export redeclaration 'operator new' here since the previous declaration is not exported
11 | export void* operator new(size_t); // 1
| ^
note: previous declaration is here
test.cppm:12:18: error: cannot export redeclaration 'operator new[]' here since the previous declaration is not exported
12 | export void* operator new[](size_t); // 2
| ^
note: previous declaration is here
test.cppm:13:17: error: cannot export redeclaration 'operator delete' here since the previous declaration is not exported
13 | export void operator delete(void*) noexcept; // 3
| ^
note: previous declaration is here
test.cppm:14:17: error: cannot export redeclaration 'operator delete[]' here since the previous declaration is not exported
14 | export void operator delete[](void*) noexcept; // 4
| ^
note: previous declaration is here
4 errors generated.
```
#### targeting x86_64-windows-msvc
```shell
✗ clang --target=x86_64-windows-msvc -std=c++20 --precompile test.cppm
test.cppm:9:18: error: cannot export redeclaration 'type_info' here since the previous declaration is not exported
9 | export class type_info; // 0
| ^
note: previous declaration is here
test.cppm:11:18: error: cannot export redeclaration 'operator new' here since the previous declaration is not exported
11 | export void* operator new(size_t); // 1
| ^
note: previous declaration is here
test.cppm:12:18: error: cannot export redeclaration 'operator new[]' here since the previous declaration is not exported
12 | export void* operator new[](size_t); // 2
| ^
note: previous declaration is here
test.cppm:13:17: error: cannot export redeclaration 'operator delete' here since the previous declaration is not exported
13 | export void operator delete(void*) noexcept; // 3
| ^
note: previous declaration is here
test.cppm:14:17: error: cannot export redeclaration 'operator delete[]' here since the previous declaration is not exported
14 | export void operator delete[](void*) noexcept; // 4
| ^
note: previous declaration is here
5 errors generated.
```
The strange thing is that other overloads of `operator new` and `operator delete` can be exported without error.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsmEuzojgUxz9N2JzCgoTngoWPdje72XdFcoR0YcIkQe359FNofNa93bbeu5m6FoUSwi8n_5wHhlsrG4VYkXRG0kXAB9dqU7UDV80_Uv2QKlhp8bMilJ0PIFnk0LpJ3fcbkkUkWpBo6s9ZdDxqQmfjcWjdaDF0SNjspitlUtXdIBAIm1snBK4nLWHfrjvhvtfGwREA46h3FNw7NAoIpXM_IqX-fu47AgB4Tt1xa8H97PG7VGtN2Ax-9yF0SegSbmZ5RdxqKQidgu7RcKcNKNwRWlj5L353hJbvDuG58WPEw-o8wPVU-ib1ghTYoUNCCz8YoSUojfsae3dH9kT2GPFk5--4npr8QtVfWTuHsxD3fE9On7T3XbLnZifnWtw5_J1rX6LFcdOgk6qBfZF9z5Kwk2rYh40a7gi2xa7zbd8oKeekzEePVQ2E4ZFC2OIeAqF1grCFDzgaQRj2Bmu96aUPmWOgHsCXSzaN4_FUEDYFNEab8UfNldLuJJlBgXXHDXdSjzGW33p5Di0aBCtVjeBahN7gVurBwvVj0sIFieK8LnEMJJ_D58QSnNm3HVOfXZR2OM73PYvHib2hGH1NMe9tL-pGH9Lt-YzxSdqx8ZQ_pd0pAbwoHHtLuA9Kim-L9qpmycuafYzLJQ8p91zy_1D1kqNQFhpUo3EoJk_n6Z1UQu9suLHb-pVUfc15PluXf5x6Lq85Ly4_lPfL__J71Cfmma-q9lXVvqraV1X7H1W19I-q2t8tgnWGq2YUZSxo0oJruQPtWjSgt2g6zYUF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