Skip to content

[Clang] CTAD for alias template failed as a default type argument is not used for deduction #133132

@MagentaTreehouse

Description

@MagentaTreehouse
template <class T>
struct A {};

template <class T>
using Foo = A<A<T>>;

template <class T = int>
using Bar = Foo<T>;

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 'T'
    8 | using Bar = Foo<T>;
      | ^
<source>:8:1: note: implicit deduction guide declared as 'template <class T> requires __is_deducible(Foo, A<A<T>>) && __is_deducible(Bar, A<A<T>>) Bar() -> A<A<T>>'
<source>:8:1: note: candidate function template not viable: requires 1 argument, but 0 were provided
    2 | struct A {};
      |        ~
    3 | 
    4 | template <class T>
    5 | using Foo = A<A<T>>;
    6 | 
    7 | template <class T = int>
    8 | using Bar = Foo<T>;
      | ^
<source>:8:1: note: implicit deduction guide declared as 'template <class T> requires __is_deducible(Foo, A<A<T>>) && __is_deducible(Bar, A<A<T>>) Bar(A<A<T>>) -> A<A<T>>'
1 error generated.

See https://compiler-explorer.com/z/57KcEqG9K.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"confirmedVerified by a second party

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions