<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=http://email.email.llvm.org/c/eJzFVktv4zYQ_jXyhbAhU5ZjH3xI7ATtobctAuwloCjKYkuJgkjF2X_fb0jJjyS7XaBA15D1mPd8MxyysOW33d6I9shO2hjme308qp4JJm3TaSO8ti1TfW97CPg6ye6T9JCk98sFZJxuOqNYY8sBD9161VdCqiAJtldgC69YNbQyGJLCGA1f4kKyxV9KetYJ51TJvGXaRw-cPJACEX0t_EWn6m0D5uiXVKNRI5qihN-TlhQOtBRzolFMtdLYIOSk7VR0EO9fau1i7lIMTgWdyhpjTyQeUQAgAQJkz5J1euyV8uC6hew60Nbj_yJUqkq3OsQasAhBNEDZIMeWPhJ-9_L1eXs29ZiH19-_Pr-kjyuvnH99_NO_PL5-eYEoE46J1iK2_so2QvmQSS26TrWO2dZ8Y7oK6VBaQAMlg0Anes9sdYEPpk8K6Sd8oz1AaFkBYstCbRvV-tgDA3yS3hnTqJ7wPUNvjJrCOEvqFydOSduWky9ETKnhwU61lvVt05Hp2GpjTAnfLj5k6JRqHPUE_DiLQP7WcABnr6LXMdYxzEsZjaVaogUAfzEcqUS1952jduZPuEB0C2Nem4Xtj_h2tT29gLiQR51kT7pMskOWbfnqOpzbPogMlCRe4VO9dRZIjNmf5ZPsIfJZfABqEkuyvQMWLeJ7fC8yWjovKchKg8ZnT1gUJB-kXq0uoxtUkzisAoZjaHeTRfx65Ye-Je4m4fw3YG2pks-2N2XCl6CR3hRDcnf4NL14p4p-F4Hvph5xR51o-dnBlD9og2nojDq3qIaGmqxekNQWWCrRXGM5yrQ-KlHun4EzAZjkD0l-wAta2HnmfEmRZPdjkfgaZt4guGVQv7ClHUIEuILA9I51nOT7lh7ZAyNMryD-lX7HZlj-ZL33VzsD5iPGWukuJbrVkLS1JPwBF5s_0zCfh3gPMhK5CASjC9Bwl5NsReNHS-3nsczuI2neiI7IZ4F516txYLP5Gxttzd-3IPUqm9srQieb_ztcsDE8s8NNEGwu2bSaKMLwbn9QinuDLbeleTAWgkb-OGTDksSgxfpqlKCefzeaS11VqseAn0b5L6whKlcM2pzJnaCzxmHxU4jMyl1WbrOtmInB17bf1cPRimY29GZ3O-aP2IyHYgGw8EHjfnygcywdQ_CpnRuUw0ue8YzP6l2arddqneabzXalslVe5mlaclWUq-2WF8VyZkShjNvFVTv77y71jqecp8vlenmX53yzSMtNli03y2VR5FtVpckqVY3Q5rxhzfpdMEm7GJhGO3_ZzWZ0PDq2Sk0Reu2N2v0xlQQ7OwYqIsHeGMcupv-_H2A-P5FwHuXjSczNQmq7kNc_87tHNQ>53232</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Modules - unexpected error "definition with same mangled name as another definition" with lambdas
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
hugoam
</td>
</tr>
</table>
<pre>
Clang will trigger a compilation error with:
1. a simple module interface with a template function calling a function object passed to it
2. a call to that function from a module passing a lambda twice in the same enclosing scope
This will cause the following compiler error: `greetings.cpp:6:6: error: definition with same mangled name '_ZW9greetingsE5greetIZW_0E4testvEUt_EvT_' as another definition`
This happens only if the use in 1. is part of a module as well (it can be an implementation unit of the same module, or it can also be part of a second module `test` which will trigger the error as well).
This seems to be some kind of variation of the following long closed bug: https://bugs.llvm.org/show_bug.cgi?id=33924
greetings.cpp
```
export module greetings;
import <string>;
export template <class Func>
void greet(Func f)
{
return f("Hello, World!");
}
```
test.cpp
```
module greetings;
// this would trigger the error as well:
// export module test;
import <iostream>;
int test()
{
greet([](const std::string& text) { std::cout << text << '\n'; });
greet([](const std::string& text) { std::cout << text << '\n'; });
return 1;
}
```
Compilation commands:
```
clang++ -Wall -std=c++2a -stdlib=libc++ -fimplicit-modules -fimplicit-module-maps -fmodules --precompile -x c++-module greetings.cpp -o greetings.pcm
clang++ -Wall -std=c++2a -stdlib=libc++ -fimplicit-modules -fimplicit-module-maps -fmodule-file=greetings.pcm -c test.cpp -o test.o
```
Alternate command if `test.cpp` is meant to be part of a different module:
```
clang++ -Wall -std=c++2a -stdlib=libc++ -fimplicit-modules -fimplicit-module-maps -fprebuilt-module-path=. -c test.cpp -o test.o
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzFVktzozgQ_jX4orLLiPh18CGxndo97G22UjWXlBDCaFcgCgk78-_3awn8SDKP006KGOh3f93qJrfFt-3OiObIztoY5jt9PKqOCSZt3WojvLYNU11nOwj4Kskek_k-mT-mM8g4XbdGsdoWPW668aorhVRBEmyvwBZesbJvZDAkhTEavsSVZPN_lPSsFc6pgnnLtI8eOHkgBSL6SvirTtnZGszBL6lGo0bUeQG_Zy0pHGgp5kStmGqksUHISduq6CD-fqm0i7lL0TsVdEprjD2TeEQBgAQIkD1LlvNjp5QH181k24K2HP6vQoUqdaNDrAGLEEQNlA1ybOgl4avXry-bi6nDIjz--fXldX548Mr50-Fv_3o4fXmFKBOOicYitu7GNkL5kEkl2lY1jtnGfGO6DOlQWkADJYNAKzrPbHmFD6bPCuknfK09QGhYDmLDQm1r1fjYAz18kt4F06ie8B1DbwyawjhL6lcnTknbFKMvREyp4cbOlZbVfdOR6dhqQ0wJ38w-ZOiUqh31BPw4i0D-1XAAZyfR6RjrEOa1jMZSLdECgD_vj1SiyvvWUTvzZ1wgupkxp3pmuyPeXWXPryDO5FEn2bMukmyfZRv-cBvOfR9EBkoSr_Cq3loLJIbsL_JJ9hT5LN4ANYkl2c4BiwbxHd6LDJYuRwqy0qDx2TMOBckHqZPVRXSDahKHlcBwCG01WsRfp3zfNcRdJ5z_AawtVfLFdqZIeAoa6Y0xJKv9p-nFX6rodxH4buoRd9SJjp_tTfGDNhiHzqBzj2poqNHqFUltgaUS9S2Wg0zjoxLl_hk4I4DJ4ilZ7PGAFnaeOV9QJNnjUCS-hJk3CG4Y1K9safsQAa4gMD7jHCeLXUO37IkRpjcQ_06_QzOkv1jv3c1mwHzEWCvctUT3G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