Is something wrong with the compiler ?

The Beardless Wonder rmj at tcom.stc.co.uk
Wed Oct 3 22:19:10 AEST 1990


In article <1895 at tuvie> hp at vmars.tuwien.ac.at (Peter Holzer) writes:
}scjones at thor.UUCP (Larry Jones) writes:
}
}>In article <BURLEY.90Sep27013312 at world.std.com>, burley at world.std.com (James C Burley) writes:
}>>    >	      a = ( int )(( unsigned ) ( a = ~0 ) >> 1 ));
}>> 
}
}>No, '=' is not a sequence point.  The question in this case is not when
}>the lhs gets evaluated, but when the actual storage of the rhs into the
}>lhs is done.  A compiler would be completely within its rights to store
}>the final result into a and then overwrite it with ~0.
}
}Yes, but the variable 'a' was not used afterwards, so we are not
}interested in the value of a, but in the value of the complete
}expression, which is IMHO well defined (The standard says in 3.3.16:
}An assignment expression has the value of the left operand after the
}assignment).

The whole point is that "Afterwards" is not a well-defined concept here.
The value of the assignment expression is as you say, but as Larry says
the value that 'a' has on the far side of the semicolon could be ~0
without contravening the standard.
-- 
* Windsinger                 * "But soft, what light through yonder
* rmj at islay.tcom.stc.co.uk   *      airlock breaks?"
* rmj at tcom.stc.co.uk         *    --RETURN TO THE FORBIDDEN PLANET
* rmj10 at phx.cam.ac.uk        *  You've gotta be cruel to be Khund!



More information about the Comp.lang.c mailing list