Re: Please don't do this (code fragment)
Thanks. This makes sense.
On Tue, Jan 15, 2002 at 07:25:29PM +0100, Olaf Weber wrote:
> Thomas Bushnell writes:
> > Actually, the C standard does essentially guarantee two's complement
> > arithmetic. It specifies integer overflow behavior and
> > signed/unsigned conversion behavior exactly.
> It does for unsigned integers, but for signed integers overflow is
> undefined behaviour. The clearest statement of that is 3.4.3, albeit
> in an example:
> 1 undefined behavior behavior, upon use of a nonportable or erroneous
> program construct or of erroneous data, for which this International
> Standard imposes no requirements
> 2 NOTE Possible undefined behavior ranges from ignoring the situation
> completely with unpredictable results, to behaving during translation
> or program execution in a documented manner characteristic of the
> environment (with or without the issuance of a diagnostic message),
> to terminating a translation or execution (with the issuance of a
> diagnostic message).
> 3 EXAMPLE An example of undefined behavior is the behavior on integer
> Olaf Weber
> (This space left blank for technical reasons.)
> To UNSUBSCRIBE, email to firstname.lastname@example.org
> with a subject of "unsubscribe". Trouble? Contact email@example.com