http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50736
Bug #: 50736
Summary: ISO_IEC_14882-2011-5.1.2/10 - bug
Classification: Unclassified
Product: gcc
Version: 4.6.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: [email protected]
ReportedBy: [email protected]
Quote from ISO_IEC_14882-2011, 5.1.2/10:
> The identifiers in a capture-list are looked up using
> the usual rules for unqualified name lookup (3.4.1); each
> such lookup shall find a variable with automatic
> storage duration declared in the reaching scope of the local
> lambda expression. An entity (i.e. a variable or this) is
> said to be explicitly captured if it appears in the
> lambda-expression’s capture-list.
But this code successfuly compiled on gcc-4.6.1:
#include <iostream>
int main() {
using std::cout;
auto f = [&cout]() { cout << 1; }; // <<
f();
}
http://liveworkspace.org/code/ae698b7daf7b5b531beafd9faaa6a409
Intel C++ 12.1 says: error : a variable with static storage
duration cannot be captured in a lambda
niXman.