This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] PR17913:[4.0 Regression] ICE jumping into statement expression

> The following patch fix PR17913. The patch does the following:
> if the first operator of the conditional_expr is constant and
> the not relevant side of it contains label, the conditional_expr
> can't be reduced.
> The patch was bootstraped and regtested without regressions on
> i686-linux.
> OK?

Can we first determine if this code is valid at all?  Someone
optimistically added the ice-on-valid keyword, but I'm not so
sure if this test case you are fixing is valid code at all.
In fact, I'd argue that if we accepted it in the past, that
was an accepts-illegal bug.

The test case is the following:

void f(void) { 1 ? 1 : ({ a : 1; 1; }); goto a; }

So we are jumping into a statement expression.  That looks wrong.

A statement expression is an _expression_ so any kind of control
flow into or out of a statement expression is just wrong IMHO.
It's like jumping into "a + b", try defining semantics for such
a construct.

Looking at the documentation as an indication of the intent of
this extension, it appears that control flow into and out of
statement expressions is not supposed to happen:

      "A compound statement enclosed in parentheses may appear as an
   expression in GNU C.  This allows you to use loops, switches, and
   local variables within an expression."

Note, "[various control structures] *within* an expression".
So statement expressions are still just expressions, and control
flow is supposed to be within the expression.  Jumping into or
out of statement expressions was apparently never supposed to be

So I think this test case is not valid GNU C, and we really
should issue an error.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]