<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61150>61150</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[C++20] [Modules] False positive ODR Checking performs for template packs when generating BMI
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:modules
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
ChuanqiXu9
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ChuanqiXu9
</td>
</tr>
</table>
<pre>
Reproducer:
```C++
//--- foo.h
namespace std
{
template<class _Dom1>
void operator &&(_Dom1 __v, _Dom1 __w)
{
return;
}
}
//--- bar.h
namespace std
{
template<typename... _Types>
struct _Traits
{
static constexpr bool _S_copy_ctor =
(__is_trivial(_Types) && ...);
};
template<typename... _Types>
struct variant
{
void
swap(variant& __rhs)
noexcept((__is_trivial(_Types) && ...))
{
}
};
}
//--- a.cppm
module;
#include "foo.h"
#include "bar.h"
export module a;
//--- b.cppm
// expected-no-diagnostics
module;
#include "bar.h"
export module b;
import a;
```
The command line:
```
clang++ -std=c++20 a.cppm --precompile -o a.pcm
clang++ -std=c++20 b.cppm -fmodule-file=a=a.pcm --precompile -o b.pcm
```
Then we will see:
```
error: 'std::_Traits' has different definitions in different modules; first difference is defined here found data member '_S_copy_ctor' with an initializer
static constexpr bool _S_copy_ctor =
~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
note: but in 'a.<global>' found data member '_S_copy_ctor' with a different initializer
static constexpr bool _S_copy_ctor =
~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
error: 'std::variant::swap' from module 'a.<global>' is not present in definition of 'variant<_Types...>' provided earlier
swap(variant& __rhs)
^
note: declaration of 'swap' does not match
```
The confusing part is that the error is gone after we remove the seemingly meaningless foo.h.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVsGS4yYQ_Rp86bJKRiPLPvgwtnaqcthK1WYPuakQallkERBA9kwO-fYU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