Re: Why is this expression detected as undefined by GCC, Splint?



Tim Rentsch wrote:
Marcin Grzegorczyk<mgrzegor@xxxxxxxxxxxxxx> writes:
Consider this example:

struct { unsigned x:5, y:6, z:7; } s;
unsigned u;
/* ... */
s.x = (s.x++, u);

In a typical implementation, either update of `s.x` will require
reading the container object first. Now the question is: is that read
access considered a part of the side effect, or may it be considered a
part of value computation (as defined in 5.1.2.3)? If the latter,
then the behaviour is undefined.

That may be true but it's irrelevant to the semantics defined for
the abstract machine. In the abstract machine, assigning to an
lvalue commences at the point of evaluting the assignment operator,
not before.

That's your interpretation. :-)
I think this issue deserves a clarification from the WG14.
(How does one go about filing a Defect Report, anyway?)
--
Marcin Grzegorczyk
.