https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99926
Bug ID: 99926 Summary: Parameter packs and variadic arguments: Clang, gcc, and msvc differ on this one Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: matthurd at acm dot org Target Milestone: --- I found three compiler differences from three compilers: https://godbolt.org/z/cEoYrn4T8 - two are wrong. g++ trunk and 10.2 affected. I thought gcc may be correct and clang may be incorrect in this compiler difference so I filed a bug with llvm. Richard Smith surmised gcc was incorrect and clang is correct, so I have closed the clang bug and I'm opening a gcc bug here if you'll indulge me. [Note: clang issue: https://bugs.llvm.org/show_bug.cgi?id=49852] ________________ gcc, clang, and msvc all compile this fun one: auto foo(auto......) { return 42; } int add_three() { return foo<int,int>(3,4,5); } ____________________ But they argue about this curious one: [[nodiscard]] constexpr auto foo(auto...t...) noexcept {return (... + t);} int add_three() { return foo<int,int>(3,4,5);} //gcc(7), clang(12), msvc(err) int add_more() { return foo(3,4,5,6); } //gcc(18), clang(18), msvc(err) https://godbolt.org/z/cEoYrn4T8 ____________________ It looks like gcc may be failing to extend the deduction as clang does. Like clang, EDG extends it as well, Richard reported. msvc will give the same answer as clang if auto is not used and it is a normal template expansion. This leaves gcc as the outlier I guess. That gcc may be wrong makes sense, though it makes a C-style variadic after a parameter pack unreachable which is a wee semantic whole in the grammar I guess. --Matt.