https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98824
Bug ID: 98824 Summary: [C++-20] function template non-type-class-arg deduction fails with a reason that looks bogus Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: dimitri.gorokhovik at free dot fr Target Milestone: --- The code: template <auto> struct a {}; template <int i, a <i> v> constexpr auto f (a <v>) { return true; }; constexpr a <1> b; auto const p = f (a <b> {}); when compiled with 'g++ -std=c++20 -c bug-14.cpp' (g++ (GCC) 11.0.0 20210123 (experimental)), produces: bug-14.cpp:5:27: error: no matching function for call to ‘f(a<a<1>()>)’ 5 | auto const p = f (a <b> {}); | ^ bug-14.cpp:2:42: note: candidate: ‘template<int i, a<i> v> constexpr auto f(a<((const a<i>)v)>)’ 2 | template <int i, a <i> v> constexpr auto f (a <v>) { return true; }; | ^ bug-14.cpp:2:42: note: template argument deduction/substitution failed: bug-14.cpp:5:27: note: types ‘a<i>’ and ‘const a<1>’ have incompatible cv-qualifiers 5 | auto const p = f (a <b> {}); clang-12 seems to accept it (hits a non-implemented feature in a subsequent pass). The diagnostics looks confusing/misleading: -- compiler is aware of the constness of 'a <i>' -- see the signature of f() in the note for line 2. And then it seemingly removes 'const' from 'const a <i>', maybe expecting a certain strictness level in 'unify()'. However, unify() is called with strict=UNIFY_ALLOW_NONE.