[Bug c++/60096] New: c++11 lambda reference capture mistake
feng.wang@uni-ulm.de
gcc-bugzilla@gcc.gnu.org
Thu Feb 6 13:35:00 GMT 2014
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60096
Bug ID: 60096
Summary: c++11 lambda reference capture mistake
Product: gcc
Version: 4.8.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: feng.wang@uni-ulm.de
considering the following code:
[code]
#include <iostream>
int main()
{
std::cout <<
[]( int x )
{
return [&](int y)
{
return x+y;
}(2);
}(5)
<< "\n";
std::cout << []( int x )
{
return [&x](int y)
{
return x+y;
};
}(2)(5)
<< "\n";
std::cout << []( int x )
{
return [x](int y)
{
return x+y;
};
}(2)(5)
<< "\n";
return 0;
}
[/code]
the output produced by g++4.8 and g++4.9 is
[output]
7
10
7
[/output]
while the expected output is
[output]
7
7
7
[/output]
More information about the Gcc-bugs
mailing list