Issue |
130205
|
Summary |
[C++20][Modules] Weird behavior on std::tuple_element & co. reexport
|
Labels |
new issue
|
Assignees |
|
Reporter |
DanShaders
|
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
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs