[cfe-dev] Assignment expression in C++ returns its right operand (A possible bug)

Abramo Bagnara abramo.bagnara at gmail.com
Fri Feb 17 02:59:46 PST 2012


Il 17/02/2012 11:26, John McCall ha scritto:
> I don't see this as tremendously useful;  it's not particularly difficult to
> detect that there's a potential bitfield truncation occurring as part of an
> assignment.  The bigger problem, though, is that this doesn't really
> model the language;  the truncation happens as part of the assignment,
> not as part of the evaluation of the right-hand side.  That distinction
> matters a lot when the operation is a compound assignment or when
> (and many sarcastic thanks go to C++ for this wonderful feature) the
> LHS is a conditional bitfield l-value.

For the former case (compound assignment) we wanted to suggest to use
OpaqueValueExpr to properly model that case (as it seems sensible and
appropriate).

But about the conditional bitfield l-value, I definitely didn't know
that... I'm astonished. I've also noted that clang is currenty unable to
compile that.



More information about the cfe-dev mailing list