https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79620
Bug ID: 79620 Summary: decltype() inside a lambda capturing-by-value Product: gcc Version: 6.3.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: lh_mouse at 126 dot com Target Milestone: --- The following example copied from the C++17 draft [N4582] fails to compile: ---------------------------------------- void f3() { float x, &r = x; [=] { // x and r are not captured (appearance in a decltype operand is not an odr-use) decltype(x) y1; // y1 has type float decltype((x)) y2 = y1; // y2 has type float const& because this lambda // is not mutable and x is an lvalue decltype(r) r1 = y1; // r1 has type float& (transformation not considered) decltype((r)) r2 = y2; // r2 has type float const& }; } ---------------------------------------- E:\Desktop>g++ -pedantic -pedantic-errors -std=c++14 test.cpp test.cpp: In lambda function: test.cpp:8:22: error: binding 'const float' to reference of type 'float&' discards qualifiers decltype((r)) r2 = y2; // r2 has type float const& ^~