Reputation: 14462
Trying to compile this code:
const int a = 1;
auto lambda = [&]() {
&a;
};
lambda();
On clang++ everything is fine, but g++ gives an error:
error: lvalue required as unary ‘&’ operand
I haven't found anything explaining such behavior. Is it a bug in g++? Or does clang++ miss something?
Upvotes: 5
Views: 274
Reputation: 14462
It's considered to be a bug in g++: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58894
According to comments, it lasts from GCC 4.5.4 and, at that moment, not fixed in GCC 4.9.0.
Upvotes: 5