https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97819
Bug ID: 97819 Summary: Pack expansion in member initializer lists nested with their parameter list got rejected. Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: gnaggnoyil at gmail dot com Target Milestone: --- The following code got accepted by Clang 10.0 and MSVC 19.27.29112, yet fails to compile under GCC: template <class ...Ts> class foo : public Ts...{ public: template <typename T, typename ...Us> explicit foo(T &&t, Us &&...us) //: Ts(Ts(t, us))...{} -> This line is accepted //: Ts{t, us...}...{} -> This line is accepted too : Ts(t, us...)...{} // This line is rejected }; class bar{ public: explicit bar(int){} }; class qux{ public: explicit qux(int){} }; class baz{ public: explicit baz(int){} }; int main(){ foo<bar, baz, qux> x(3); (void)x; return 0; } I tried GCC version 4.9.3 with -std=c++14, 5.5.0, 6.3.0, 7.3.0 with -std=c++17, and 8.3.0, 9.3.0, 10.1.0 with -std=c++2a, all of them rejects this code. Error outputs for GCC 4.9.3, 5.5.0, 9.3.0, 10.1.0 ones are: prog.cc: In instantiation of 'foo<Ts>::foo(T&&, Us&& ...) [with T = int; Us = {}; Ts = bar, baz, qux]': prog.cc:27:27: required from here prog.cc:8:23: error: invalid use of pack expansion expression : Ts(t, us...)...{} ^ Error outputs for GCC 6.3.0, 7.3.0, 8.3.0 ones are: prog.cc: In instantiation of 'foo<Ts>::foo(T&&, Us&& ...) [with T = int; Us = {}; Ts = {bar, baz, qux}]': prog.cc:27:27: required from here prog.cc:8:23: error: no matching function for call to 'bar::bar(int&, bool)' : Ts(t, us...)...{} ^~~ prog.cc:13:14: note: candidate: bar::bar(int) explicit bar(int){} ^~~ prog.cc:13:14: note: candidate expects 1 argument, 2 provided prog.cc:11:7: note: candidate: constexpr bar::bar(const bar&) class bar{ ^~~ prog.cc:11:7: note: candidate expects 1 argument, 2 provided prog.cc:11:7: note: candidate: constexpr bar::bar(bar&&) prog.cc:11:7: note: candidate expects 1 argument, 2 provided prog.cc:8:23: error: no matching function for call to 'baz::baz(int&, bool)' : Ts(t, us...)...{} ^~~ prog.cc:23:14: note: candidate: baz::baz(int) explicit baz(int){} ^~~ prog.cc:23:14: note: candidate expects 1 argument, 2 provided prog.cc:21:7: note: candidate: constexpr baz::baz(const baz&) class baz{ ^~~ prog.cc:21:7: note: candidate expects 1 argument, 2 provided prog.cc:21:7: note: candidate: constexpr baz::baz(baz&&) prog.cc:21:7: note: candidate expects 1 argument, 2 provided prog.cc:8:23: error: no matching function for call to 'qux::qux(int&, bool)' : Ts(t, us...)...{} ^~~ prog.cc:18:14: note: candidate: qux::qux(int) explicit qux(int){} ^~~ prog.cc:18:14: note: candidate expects 1 argument, 2 provided prog.cc:16:7: note: candidate: constexpr qux::qux(const qux&) class qux{ ^~~ prog.cc:16:7: note: candidate expects 1 argument, 2 provided prog.cc:16:7: note: candidate: constexpr qux::qux(qux&&) prog.cc:16:7: note: candidate expects 1 argument, 2 provided