https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122362
Bug ID: 122362
Summary: Template partial ordering failure when a deduced
parameter pack is mixed with an explicit template
parameter
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: o.a.rogozin at gmail dot com
Target Milestone: ---
The GCC compiler of any version fails to compile the following code snippet:
template<int, class... Ts>
void f(Ts...) {} // #1
template<int, class... Ts>
void f(std::initializer_list<Ts>...) {} // #2
int main()
{
f<0>({1,2,3}); // (1) correct behavior
f<0>(std::initializer_list<int>{1,2,3}); // (2) compile error!
}
Candidate #2 is more specialized and should be preferred in both calls, but gcc
reports (2) as an ambiguous call. Clang compiles this example as is.
The issue takes place when template argument deduction is performed for a
parameter pack following a non-deduced template parameter.
See: https://godbolt.org/z/zfTxnqT3e
Related unresolved bug 67228.