c++clangc++23

variadic template failed to compile, compiler bug?


I reduced my code to this very short example:

template<class ...F>
struct A
{
    A(std::convertible_to<std::tuple<std::string, F>> auto&&... actions);
    std::tuple<std::tuple<std::string, F>...> _actions;
};

template<class ...F>
A<F...>::A(std::convertible_to<std::tuple<std::string, F>> auto&&... actions)
    : _actions{ std::tuple{ actions... } }{}

I don't see anything wrong with it. But clang (-std=c++23) gives this error:

<source>:13:66: error: pack expansion contains parameter packs 'actions:auto' and 'F' that have different lengths (1 vs. 0)
   13 | A<F...>::A(std::convertible_to<std::tuple<std::string, F>> auto&&... actions)
      |                                                        ~         ^   ~~~~~~~
<source>:13:10: note: while calculating associated constraint of template '' here
   13 | A<F...>::A(std::convertible_to<std::tuple<std::string, F>> auto&&... actions)
      |          ^
<source>:13:10: error: out-of-line definition of 'A<F...>' does not match any declaration in 'A<F...>'
   13 | A<F...>::A(std::convertible_to<std::tuple<std::string, F>> auto&&... actions)
      |          ^
2 errors generated.

Compiler Explorer Demo


Solution

  • This seems to be a clang bug that was fixed in latest clang trunk. Demo