Created attachment 40535 [details] reproducer When a simple lambda capture and a lambda parameter share a name, the capture object is seen inside the lambda. Except inside decltype, which sees the parameter. The attached testcase produces (at -O2): subq $8, %rsp movl $1, %edi <-- size of lambda parm 'z' call _Z3Barj movl $4, %edi <-- size of lambda capture 'z' call _Z3Barj movl $5, %eax <-- value of lambda capture 'z' addq $8, %rsp ret Possibly related email: https://gcc.gnu.org/ml/gcc-patches/2017-01/msg01331.html
Related: http://stackoverflow.com/questions/42088015 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57443
Core DR 2211 makes this ill-formed, so it should be rejected.
*** Bug 57443 has been marked as a duplicate of this bug. ***
CCing Ville as he reported the core issue and had assigned the PR 57443 dup to himself.
*** Bug 86361 has been marked as a duplicate of this bug. ***
Author: ville Date: Tue Aug 7 13:46:16 2018 New Revision: 263357 URL: https://gcc.gnu.org/viewcvs?rev=263357&root=gcc&view=rev Log: PR c++/79133 gcc/cp/ PR c++/79133 * name-lookup.c (check_local_shadow): Reject captures and parameters with the same name. testsuite/ PR c++/79133 * g++.dg/cpp0x/lambda/lambda-shadow3.C: New. * g++.dg/cpp1y/lambda-generic-variadic18.C: Likewise. Added: trunk/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-shadow3.C trunk/gcc/testsuite/g++.dg/cpp1y/lambda-generic-variadic18.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/name-lookup.c
Fixed.