[Bug c++/58894] C++11 lambda doesn't take const variable by reference

daniel.kruegler at googlemail dot com gcc-bugzilla@gcc.gnu.org
Sun Oct 27 13:08:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58894

Daniel Krügler <daniel.kruegler at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.kruegler@googlemail.
                   |                            |com

--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> ---
The code - as written - is invalid. Here is a valid form of this:

//-------------------------
int main() {
  const int a = 1;
  auto lambda = [&]() {
    &a;
  };
  lambda();
}
//--------------------------

It still produces the mentioned diagnostics even in gcc 4.9.0 20131026
(experimental). It doesn't seem to be a regression, I can track it down back to
gcc 4.5.4


More information about the Gcc-bugs mailing list