<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/130205>130205</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[C++20][Modules] Weird behavior on std::tuple_element & co. reexport
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
DanShaders
</td>
</tr>
</table>
<pre>
With the following code,
```cpp
module;
#include <utility>
export module test;
export namespace exported {
using ::std::tuple_element;
using ::std::tuple_size;
using ::std::integral_constant;
}
```
```cpp
#include <cstdint>
import test;
struct Foo {
template<std::size_t i>
int get() { return 0; }
};
template<>
struct exported::tuple_size<Foo> : exported::integral_constant<std::size_t, 1> {};
template<>
struct exported::tuple_element<0, Foo> { using type = int; };
void foo() {
auto [a] = Foo{};
}
```
Clang produces the following diagnostic:
```
consumer.cpp:17:10: error: type 'Foo' decomposes into 0 elements, but 1 name was provided
17 | auto [a] = Foo{};
| ^
1 error generated.
```
as if it doesn't see `tuple_size` specialization. Note that the diagnostic goes away if I add
```cpp
namespace std {
export using ::std::tuple_element;
export using ::std::tuple_size;
}
```
to the module file. I'm not sure if this code is actually UB-free according to standard but the current Clang behavior is definitely very confusing.
CE: https://godbolt.org/z/rKxYjrn11
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJycVU2L4zgQ_TXKpeggS3E8OfiQjw4My-5lWYY9NYpUdjTIkpHK6Un_-kW2u9NfzCwDITFRVem9V6_KKiXbesSalTtWHhZqoHOI9UH5v8_KYEyLUzDX-pulM9AZoQnOhUfrW9DBIBN7xrdszaeP7nvGt10wg0Mmd_mIb5mQ1ms3GAQm9wNZZ-nK5P10ij_6EAmmHCBM9JI4H3nVYeqVRpj-QAOsmkOGlJEwuWVym8hMDzT0Dh_QYYd-rvaTuGSf8CdB1hO2UbkHHXwi5W_wWHV4zf2jDm-J60TG5vSZuO1Gdm8YJ4qD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