Skip to content

Clang's error on non-pack parameter of alias template in a dependent type #84220

@jonathanpoelen

Description

@jonathanpoelen

It seems that clang does not consider sizeof...(xs) to be a dependent expression when the call to foo is made with a known number of arguments. The expression must absolutely contain xs....

The following code compiles with gcc, but not clang (https://godbolt.org/z/TYzvjTePT):

template<int>
struct foo_impl {
  template<class>
  using f = int;
};

template<class... xs> constexpr int sizeof_pack = sizeof...(xs);

template<class... xs>
using foo = typename foo_impl< // error: pack expansion used as argument for non-pack parameter of alias template
  sizeof...(xs) // does not work
  // sizeof_pack<xs...>  // ok
>::template f<xs...>; // f is dependent on xs

template<class... xs>
using test = list<foo<xs>...>;

// template<class... xs>
// using test = foo<xs...>; // ok with pack...

test<int> a; // ko

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