<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/109879>109879</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] Asserts in ADL when finding exported declaration in the implicit global module
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
mizvekov
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
mizvekov
</td>
</tr>
</table>
<pre>
Repro:
```C++
//--- A.cppm
module;
export module A;
export extern "C" void foo(struct Bar);
//--- B.cppm
module;
import A;
export module B;
//--- C.cpp
import B;
struct Bar {};
void test() {
foo(Bar());
}
```
Crashes with:
```
Assertion failed: (FM && FM->isNamedModule() && !FM->isPrivateModule() && "bad export context"), function ArgumentDependentLookup, file SemaLookup.cpp, line 3854.
```
This is not just a crash on invalid. Slightly more complex, but valid, example:
```C++
//--- foo.h
struct Bar {};
extern "C" void foo(struct Bar);
//--- A.cppm
module;
#include "foo.h"
export module A;
export extern "C" using ::foo;
//--- B.cppm
module;
import A;
export module B;
//--- C.cpp
// expected-no-diagnostics
import B;
#include "foo.h"
void test() {
foo(Bar());
}
```
It seems the comment above the assert is correct, but the assert itself is missing the implicit global module case, which is also in module purview.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VWGPozYQ_TXOl1GQY5IAH_hAkkaqdFtVvf4BAxOYO2Mj27B7_fWVDbm92-1uq6tOQkLMjMfvPb_B0jnqNGLJDicmxEB_zfjZzEwIdrhs5OR7Y8t7dFOb9kv5B47WsLRi_MJ4xY58ec5MnMKzRMWViet2u4UqacZxWKKDaSeFLF2L8Gk01sMSheplHJ88Wg1MiDMTAmZDLdyMYSJ33k6Nh5O0TBRfl73c-fT2zjTEHV5tuUI5vdnzHHp-1-O59hkVsOzEssvXTITu0XkmciaKmI6JlU8kEjLf0ckuLxT-FtLZStejg0fy_euzWD4r59B6MhpukhS2LK2Aifz6AEwcmTjC9WHL0l_I_SYHbB8WiVaESwETu3vN75Zm6fGfq0QtW1g1bIz2-OSDgwKhM9wm3UQUle2mAbW_4Ii6Re0_GPN5GmMNKYSPOMglFFUWZ1CkEdL8sE_ekeLPnhyQA208fJqcBwlNUAeMBtKzVNQm8FFR13v1BQZjERozjAqfwhb15CHWhA98kiHxn819Mybp_-30_6-P35kgJlLSjZpaDO0XNEL8yHRNjnQHgXhaBXDpK64_eZyWYDARNh7brTbblmSnjfPUuDdG7j3-bw_dj0_drx4c4uDA99FEwc0gazNjjMg4cMGLjbEWG3832LdJ71DdQs1ALooekjSMihry0ClTS3VXrpEOQ4_Hnpo-rJHKGSB9z4-TnQkfk01bpm2RFnKD5S4Tmdjl-e646UuZHdLjDnkuC37IUMh9ym_Ii2Mhs13GxYZKwcWeF2IvUs53h6TmPD8ib_c55keJNdtzHCSpRKl5SIztNuTchOWOF3lWbJSsUbn19miU1N16ddgyLNjWU-fYnity3j238ORVvHKWFYcLLP8qF7hVlw_w2KOGG-k2CLS4CVtosVHSyvgzIf2OcJvJqrL3fnTB0dFZHfl-qpPGDExcA5D1tR2t-RSP6hqJOSauK7e5FH8HAAD__7w4F0E">