llvm-project
llvm-project copied to clipboard
[Clang] Missing default template argument in synthesized guides during CTAD for alias template
template <class T, auto = 0>
struct A {
A(T) {}
};
template <class T, class U>
using Foo = A<T, U{}>;
template <class T, class U = int>
using Bar = Foo<T, U>;
Bar a{0};
Output:
<source>:12:5: error: no viable constructor or deduction guide for deduction of template arguments of 'Bar'
12 | Bar a{0};
| ^
<source>:10:1: note: candidate template ignored: couldn't infer template argument 'U'
10 | using Bar = Foo<T, U>;
| ^
<source>:10:1: note: implicit deduction guide declared as 'template <class T, class U> requires __is_deducible(Foo, A<T, U{}>) && __is_deducible(Bar, A<T, U{}>) Bar(T) -> A<T, U{}>'
<source>:10:1: note: candidate template ignored: could not match 'A<T, U{}>' against 'int'
<source>:10:1: note: implicit deduction guide declared as 'template <class T, class U> requires __is_deducible(Foo, A<T, U{}>) && __is_deducible(Bar, A<T, U{}>) Bar(A<T, U{}>) -> A<T, U{}>'
See https://compiler-explorer.com/z/vcjc1qEfv. See also #133132.
@llvm/issue-subscribers-clang-frontend
Author: None (MagentaTreehouse)
```c++
template <class T, auto = 0>
struct A {
A(T) {}
};
template <class T, class U> using Foo = A<T, U{}>;
template <class T, class U = int> using Bar = Foo<T, U>;
Bar a{0};
Output:
```console
<source>:12:5: error: no viable constructor or deduction guide for deduction of template arguments of 'Bar'
12 | Bar a{0};
| ^
<source>:10:1: note: candidate template ignored: couldn't infer template argument 'U'
10 | using Bar = Foo<T, U>;
| ^
<source>:10:1: note: implicit deduction guide declared as 'template <class T, class U> requires __is_deducible(Foo, A<T, U{}>) && __is_deducible(Bar, A<T, U{}>) Bar(T) -> A<T, U{}>'
<source>:10:1: note: candidate template ignored: could not match 'A<T, U{}>' against 'int'
<source>:10:1: note: implicit deduction guide declared as 'template <class T, class U> requires __is_deducible(Foo, A<T, U{}>) && __is_deducible(Bar, A<T, U{}>) Bar(A<T, U{}>) -> A<T, U{}>'
See https://compiler-explorer.com/z/vcjc1qEfv. See also #133132.
Reduced a bit:
template <auto>
struct A {};
template <class U>
using Foo = A<U{}>;
template <class U = int>
using Bar = Foo<U>;
Bar a{};
Output:
<source>:10:5: error: no viable constructor or deduction guide for deduction of template arguments of 'Bar'
10 | Bar a{};
| ^
<source>:8:1: note: candidate template ignored: couldn't infer template argument 'U'
8 | using Bar = Foo<U>;
| ^
<source>:8:1: note: implicit deduction guide declared as 'template <class U> requires __is_deducible(Foo, A<U{}>) && __is_deducible(Bar, A<U{}>) Bar() -> A<U{}>'
<source>:8:1: note: candidate function template not viable: requires 1 argument, but 0 were provided
2 | struct A {};
| ~
3 |
4 | template <class U>
5 | using Foo = A<U{}>;
6 |
7 | template <class U = int>
8 | using Bar = Foo<U>;
| ^
<source>:8:1: note: implicit deduction guide declared as 'template <class U> requires __is_deducible(Foo, A<U{}>) && __is_deducible(Bar, A<U{}>) Bar(A<U{}>) -> A<U{}>'
1 error generated.