Skip to content

[Clang] Missing default template argument in synthesized guides during CTAD for alias template #164264

@MagentaTreehouse

Description

@MagentaTreehouse
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions