https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96213
Bug ID: 96213 Summary: GCC doesn't complain about ill-formed non-dependent template default argument Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: arthur.j.odwyer at gmail dot com Target Milestone: --- Possibly related (although these seem to complain about the opposite of what I'm complaining about): - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=12672 - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58071 // https://godbolt.org/z/EYzxx9 template<class> int g; template<int = g<int>(0,1,2)> void h() { } int main() { h<1>(); } MSVC and Clang both reject template `h` as ill-formed, because `g<int>(0,1,2)` is nonsense -- `g<int>` is an `int` and thus cannot be called like a function. GCC accepts template `h` as well-formed, and in fact will treat this as a SFINAE situation: template<class> int g; template<int = g<int>(42)> void h() {} // #1 template<class = void> void h() {} // #2 int main() { h<>(); // unambiguously calls #2, because #1 has a deduction failure } My guess is that MSVC and Clang are closer to correct here.