On Wed, Dec 11, 2013 at 07:13:47PM +0530, Prathamesh Kulkarni wrote: > >From the bug-report (comment 4): > Here is what the c++ standard says : > "The break statement shall occur only in an iteration-statement or a switch > statement and causes termination of the smallest enclosing iteration-statement > or switch statement; control passes to the statement following the terminated > statement, if any." > So the break (if the expression statement extension is activated) is > considered > in the inner loop with this extension. > > So I guess g++ should compile it ? > g++ rejects it too: > foo.cpp:3:14: error: break statement not within loop or switch > while ( ({ break; 0; }) )
Statement expressions are GCC extensions and without that extension, you can't put a break or continue anywhere in a loop but in the loop body, so the exact wording of the standard isn't that important, for standard conforming C and C++ that wording nuances make no difference, what matters is how we define the extension and (ideally) document it if it isn't documented yet. Similarly what exactly clang implements here isn't that important, as they just implemented the GCC extension, either correctly, or not. Jakub