Bug 57443

Summary: Captured variable hide the parameter if they have the same name in Lambdas
Product: gcc Reporter: koushik <kou4307>
Component: c++Assignee: Ville Voutilainen <ville.voutilainen>
Status: RESOLVED DUPLICATE    
Severity: normal CC: ville.voutilainen, webrown.cpp
Priority: P2 Keywords: accepts-invalid, c++-lambda, wrong-code
Version: 4.7.1   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2013-06-03 00:00:00
Bug Depends on:    
Bug Blocks: 54367    

Description koushik 2013-05-28 18:34:55 UTC
Here is the Stack overflow link that i have shared the problem (http://stackoverflow.com/questions/16798079/captured-variable-hides-passed-variable-in-lambda-how-to-unhide/16798406#16798406)

I will expand the example here

int main()
{
    int a = 1;
    std::cout<<[=,&a](int a,int b){return a+b;}(99,1);
    return 0;
}

Here the output is 2 rather than 100.

as the answer in the link says this problem in present in gcc 4.7.2 and gcc 4.8
Comment 1 Ville Voutilainen 2015-10-23 10:07:14 UTC
Mine.
Comment 3 Ville Voutilainen 2017-03-18 15:02:12 UTC
The resolution of Core Issue 2211 makes such code ill-formed.
Comment 4 Jonathan Wakely 2018-04-24 12:24:35 UTC
dup

*** This bug has been marked as a duplicate of bug 79133 ***