Bug 57443 - Captured variable hide the parameter if they have the same name in Lambdas
Summary: Captured variable hide the parameter if they have the same name in Lambdas
Status: RESOLVED DUPLICATE of bug 79133
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.1
: P2 normal
Target Milestone: ---
Assignee: Ville Voutilainen
URL:
Keywords: accepts-invalid, c++-lambda, wrong-code
Depends on:
Blocks: lambdas
  Show dependency treegraph
 
Reported: 2013-05-28 18:34 UTC by koushik
Modified: 2022-03-11 00:32 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2013-06-03 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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 ***