Issue |
154065
|
Summary |
Clang argument deduction failure within nested generic lambda
|
Labels |
clang
|
Assignees |
|
Reporter |
sneed-deens
|
Latest GCC and MSVC able to compile, latest Clang don't ([Godbolt](https://godbolt.org/z/9YbMbez67)).
Compiled with: `-std=c++20 -Wall -Wextra -Wpedantic`.
`x86-64 Clang 14.0.0` also able to compile (any version above don't).
Factoring out part with problematic deduction also makes it compile ([Godbolt](https://godbolt.org/z/Wv5zEncT3)).
```
using Index = int;
using Alignment = int;
struct Key {
Index old;
Alignment a;
};
template<Key k, typename T> struct Elem {};
template<typename ...Elems> struct Map : Elems... {};
template<typename ...Ts> struct Tuple {};
// removing 't' parameter makes it compile,
// so sort_tuple should be template to trigger error
constexpr auto sort_tuple(auto t)
{
(void)t;
using M = ::Map<
::Elem<::Key{0, 1}, char>
>;
// this lambda should be generic to trigger error
using Sorted = decltype([]<auto ...Is>(
){
return ::Tuple<
decltype([]<::Key k, typename T>(
[[maybe_unused]] ::Elem<k, T>&& deduced
){
return T{};
}.template operator()<::Key{0, 1}>(M{}))
>{};
}.template operator()<1,2,3>());
return Sorted{};
};
using T1 = Tuple<char, short, int, double>;
using Sorted = decltype(sort_tuple(T1{}));
int main() {}
```
Error from Compiler Explorer:
```
<source>:30:18: error: no matching member function for call to 'operator()'
26 | decltype([]<::Key k, typename T>(
| ~~~~~~~~~~~~~~~~~~~~~~~~
27 | [[maybe_unused]] ::Elem<k, T>&& deduced
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
28 | ){
| ~~
29 | return T{};
| ~~~~~~~~~~~
30 | }.template operator()<::Key{0, 1}>(M{}))
| ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
<source>:24:4: note: while substituting into a lambda _expression_ here
24 | ){
| ^
<source>:38:25: note: in instantiation of function template specialization 'sort_tuple<Tuple<char, short, int, double>>' requested here
38 | using Sorted = decltype(sort_tuple(T1{}));
| ^
<source>:26:16: note: candidate template ignored: deduced type '::Elem<k, T>' of 1st parameter does not match adjusted type 'M' (aka 'Map< ::Elem< ::Key{0, 1}, char>>') of argument [with k = Key{0, 1}, T = char]
26 | decltype([]<::Key k, typename T>(
| ^
1 error generated.
Compiler returned: 1
```
This minimized example made from code that sorts tuple's types, where
GCC also unable to compile ([Godbolt](https://godbolt.org/z/YPh1aMnco), if interested).
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs