This code fails to compile with any current version of g++ from 4.7 to 7.0: ``` int main(){ _infinite_retry: [=]{ _infinite_retry: goto _infinite_retry; // go to the second _infinite_retry. }(); goto _infinite_retry; // go to the first _infinite_retry. } ``` D:\Desktop>g++ test.cpp -Wall test.cpp: In function 'int main()': test.cpp:2:2: warning: label '_infinite_retry' defined but not used [-Wunused-label] _infinite_retry: ^~~~~~~~~~~~~~~ test.cpp:7:8: error: label '_infinite_retry' used but not defined goto _infinite_retry; // go to the outer _infinite_retry. ^~~~~~~~~~~~~~~ Quoting from the standard: ``` ISO/IEC WG21 N4582 5.1.2 Lambda expressions [expr.prim.lambda] 8 The lambda-expression’s compound-statement yields the function-body (8.4) of the function call operator, ... 3.3.5 Function scope [basic.funscope] 1 Labels (6.1) have function scope and may be used anywhere in the function in which they are declared. Only labels have function scope. ``` The compound statement of a lambda expression is a function body thus it creates a function scope. The second label should reside in that scope but somehow nullifies the first one, causing the second goto statement to fail to find the first label.
clang++ 3.0 seems to have issues dealing with this, but it seems to have been fixed since clang++ 3.1.
Very likely duplicate of PR61358, testcase slightly different, better keep both.
Indeed, now that PR61358 is fixed in trunk, this one is fixed too. I will add a testcase. *** This bug has been marked as a duplicate of bug 61358 ***