The first result is the value 3 is moved to x. In this point the operator
?: was resolved. Next, the 4 value is moved to x.In this point the operator
= (minor precedence that ?:) was resolved. To produce the asm code I'm using
the Borland C++.
Regards,
RMJ.
> > >I suspect there's a compiler bug to do with assignments in a
> > > ternary operator as the rvalue of an assignment.
> >
> > The expression is correct.
>
> The _expression_ is correct - the _compiler_ is buggy.
>
> > > Wrapping the two x='s on
> > > the right-hand side generates the expected output.
> >
> > No. The expected output is X equal to the result of two other expression
> > (E1,E2), related to condition (y).
> > x= (condition) ? E1 : E2;
>
> I understand how ?: works. What I said was that gcc/egcc would not compile
> this line:
> x = (y) ? x = 1 : x = 2;
> But if you change it like this:
> x = (y) ? (x = 1) : (x = 2);
> then gcc/egcc don't give you an error. Try the same workaround in your own
> compiler, or upgrade it.
>
> --Jeff
>
>
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/