https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83476
Bug ID: 83476 Summary: Template argument deduction fails with reference auto template parameter Product: gcc Version: 7.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: gufideg at gmail dot com Target Milestone: --- As the title says, I have an auto reference template parameter which should be deduced, but fails in this case: constexpr auto lambda = []{}; template<auto& l> struct Lambda {}; template<auto& l> void test(Lambda<l>) {} int main() { test(Lambda<lambda>{}); } The error is: main.cpp: In function 'int main()': main.cpp:10:26: error: no matching function for call to 'test(Lambda<lambda>)' test(Lambda<lambda>{}); ^ main.cpp:7:6: note: candidate: template<auto& l> void test(Lambda<l>) void test(Lambda<l>) {} ^~~~ main.cpp:7:6: note: template argument deduction/substitution failed: main.cpp:10:26: note: couldn't deduce template parameter 'l' test(Lambda<lambda>{}); ^ The non-type template parameter should be deduced as any other non type template parameter. Here's this example at godbolt: https://godbolt.org/g/HV4Wpf