https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115504
Bug ID: 115504 Summary: Wrong decltype result for a captured reference inside limbda Product: gcc Version: 14.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: fchelnokov at gmail dot com Target Milestone: --- This program ``` template<class T> int foo() = delete; template<> int foo<int&>() { return 0; } int main() { int y = 0; int &i = y; return [&i]() { decltype(auto) x = i; return foo<decltype(x)>(); }(); } ``` is accepted in Clang, MSVC and GCC 13.3, but not in GCC 14, which thinks that `decltype(x)=int`. Online demo: https://gcc.godbolt.org/z/fc1nrP4P9 Related discussion: https://stackoverflow.com/a/78626163/7325599