http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49043
Summary: Returns from lambda functions incorrectly detected as "exits" from OpenMP loops in surrounding code Product: gcc Version: 4.6.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: bisq...@iki.fi GCC incorrectly considers return statements within lambda functions as "exits" from an OpenMP structured block. For the code below, this error message is generated: tmp3.cc: In lambda function: tmp3.cc:7:40: error: invalid exit from OpenMP structured block #include <iostream> int main() { #pragma omp parallel for for(int a=0; a<10; ++a) { auto func = [=] () { return a; }; std::cout << func(); } } Compiled with: -fopenmp -std=gnu++0x Tested versions: 4.5.3 , 4.6.1 The purpose of this error is to catch exits from an OpenMP construct (return, break, goto). No such thing happens when a lamdba function is called, which is not different from calling an inlined function, therefore the error message is misplaced.