[Bug c++/60463] Lambda function can call a non-const member function with const this
momchil.velikov at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sat Apr 12 19:37:00 GMT 2014
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60463
Momchil Velikov <momchil.velikov at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |momchil.velikov at gmail dot com
--- Comment #1 from Momchil Velikov <momchil.velikov at gmail dot com> ---
Just stumbled upon essentially the same problem with
c++ (GCC) 4.10.0 20140412 (experimental) [master revision
094da06:e25c6c8:855372a3d3c40b76fed8ff368d37b77d14a488eb]
#include <iostream>
struct S {
void foo() const;
void bar();
int x = 0;
};
void S::foo() const {
auto f = [&]() { bar(); };
f();
std::cout << x << std::endl;
}
void S::bar() { ++x; }
int main() {
S s;
s.foo();
return 0;
}
More information about the Gcc-bugs
mailing list