https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61358
Bug ID: 61358
Summary: Bogus "duplicate label" error after label used within
C++11 lambda
Product: gcc
Version: 4.8.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: arthur.j.odwyer at gmail dot com
cat >test.cc <<EOF
int main() {
goto doit;
[]() { doit: ; };
doit: ;
}
EOF
g++ -std=c++11 -c test.cc
test.cc: In function `int main()':
test.cc:2:8: error: label `doit' used but not defined
test.cc:5:1: error: duplicate label `doit'
Reproduces with 4.6.2, 4.6.4, and 4.8.1. I don't have 4.9 available to test
with.
The same thing happens if you use a statement-expression ({ doit: ; }); instead
of a C++11 lambda, but that might be not-a-bug. The C++11 issue is definitely a
bug.
If anyone still cares about Objective-C "blocks" in GCC, you might check for
the same issue with labels inside blocks.
This bug is actually important to us because we code-generate C++11 code, and
the code-generator wants to use the same labels for the same purposes whether
we happen to be inside a lambda or not.