This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Scopes in which __label__ can appear
Mark Mitchell <mark@codesourcery.com> writes:
| > | It would be very odd for it to work one way in statement-expressions,
| > | but another way elsewhere
| >
| > No, what is confusing is the notion os statement-expression.
| > don't act like anything else in the language. Trying to have people
| > believe that statement-expressions act like anything else in the
| > language is creating promises and time-bomb confusion.
| > It should be made clear that statement-expression don't behave like
| > ordinary scopes.
|
| But they do act like ordinary scopes;
Ordinary scopes don't yield a value.
Statement-expressions act much like inline (nested) functions.
| that is a large portion of the
| reason for their existence. You can declare local variables in them,
| for example, and variables with destructors declared in a
| statement-expressions are destroyed before exiting the
| statement-expression.
| The intended semantics of __label__ are quite clear. The manual calls
| them "local labels" because they are local to a scope. The manual only
| talks about using them in statement-expressions, but it does have
| examples where they are used outside statement-expressions. The C++
| front end already implements the semantics I suggested, so doing as you
| suggest would potentially break working code there.
In C or in C++? Clearly, Zack's patch implements a change in
semantics, and statement-expressions are much more used in C than in
C++, and there are higher probablity to break codes there than in C++
land (we got a testcase).
| Furthermore, the implementation of the semantics I suggest falls out
| automatically. It is harder to special-case statement-expressions that
| simply to do what I suggest.
statement-expressions are sort of inline functions, and the semantics
there just parallel that of ordinary functions. In fact, there is no
special case. In fact, I would say the special-casing goes the other
way around.
| I've got nothing more to say on this issue.
Given that the patch is already applied by a global priv maintainer
without reaching consensus, sure. :-(
-- Gaby