Messages in this thread | | | From | Paul Wagland <> | Subject | Re: MSEC_TO_JIFFIES is messed up... | Date | Sun, 16 May 2004 14:10:06 +0200 |
| |
On May 16, 2004, at 5:48, Chris Wedgwood wrote:
> On Wed, May 12, 2004 at 11:55:18PM +0200, Andreas Schwab wrote: > >> Signed integer overflow is undefined in C, so the compiler is >> allowed to assume it does not happen. > > Really? > > Just because something is undefined assuming it never happens is a bit > of a leap of faith IMO.
More precisely, if something has undefined semantics then the compiler is allowed to do whatever it likes. Normally the compiler will try to do "what's right", but if they have an optimisation opportunity then they will normally take it.
In other words by assuming it "doesn't happen" they get to perform an optimisation that they could not do otherwise, and they get to perform "correctly" in an undefined way when the overflow would happen.
Cheers, Paul [unhandled content-type:application/pgp-signature]
| |