Before reading the rest of this answer, please read Go To Statement Considered Harmful. If you don't want to read it in full, here is what I consider the key point:
The unbridled use of the go to statement has an immediate consequence that it becomes terribly hard to find a meaningful set of coordinates in which to describe the process progress.
Or to rephrase, the problem with goto
is that the program can arrive in the middle of a block of code, without the programmer understanding the program state at that point. The standard block-oriented constructs are designed to clearly delineate state transitions, a labeled break
is intended to take the program to a specific known state (outside of the containing labeled block).
In a real-world imperative program, state is not clearly delineated by block boundaries, so it is questionable whether the labeled break
is a good idea. If the block changes state that is visible from outside the block, and there are multiple points to exit the block, then a labeled break
is equivalent to the primitive goto
. The only difference is that, rather than the chance of landing in the middle of a block with indeterminate state, you start a new block with indeterminate state.
So, in general, I would consider a labeled break
as dangerous. In my opinion it is a sign that the block should be converted into a function, with limited access to enclosing scope.
However, this example code was clearly the product of a parser generator (the OP commented that it was Xerces source code). And parser generators (or code generators in general) often take liberties with the code they generate, because they have perfect knowledge of state and humans don't need to understand it.