https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102283
Bug ID: 102283 Summary: Inconsistent/wrong overload resolution when using an initializer list and a defaulted template parameter Product: gcc Version: 11.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: dangelog at gmail dot com Target Milestone: --- Hello, The following testcase has an "inconsistent" overload resolution: template <typename U> struct helper {}; struct data {}; template <typename T, typename E> struct S { template <typename T2=T> void f(T2 &&); // #1 template <typename E2=E> void f(const helper<E2> &); // #2 }; int main() { S<int, int> s1; S<data, int> s2; s1.f({}); s2.f({}); } https://gcc.godbolt.org/z/nsj48M7af On GCC 11, the the first call to f() resolves to #1, but the second call resolves to #2. I cannot find any reason for this inconsistency in the ranking of the overloads; no warnings are emitted under -Wall -Wextra. Clang and MSVC both always call #1.