https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79378
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2017-02-06 Ever confirmed|0 |1 --- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- We also get the r2 case wrong for the example in [expr.prim.lamda] p20: template <class T, class U> struct is_same { static constexpr bool value = false; }; template <class T> struct is_same<T, T> { static constexpr bool value = true; }; 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; static_assert(is_same<decltype(y1), float>::value, "y1 has type float"); decltype((x)) y2 = y1; static_assert(is_same<decltype(y2), float const&>::value, "y2 has type float const& because this lambda is not mutable and x is an lvalue"); decltype(r) r1 = y1; static_assert(is_same<decltype(r1), float&>::value, "r1 has type float& (transformation not considered)"); decltype((r)) r2 = y2; static_assert(is_same<decltype(r2), float const&>::value, "r2 has type float const&"); }; } lam2.cc: In lambda function: lam2.cc:13:20: error: binding reference of type ‘float&’ to ‘const float’ discards qualifiers decltype((r)) r2 = y2; ^~ lam2.cc:14:1: error: static assertion failed: r2 has type float const& static_assert(is_same<decltype(r2), float const&>::value, "r2 has type float const&"); ^~~~~~~~~~~~~