Integer overflow and underflow semantics

Mehrdad wfunction at hotmail.com
Sun May 6 09:39:00 PDT 2012


On Saturday, 5 May 2012 at 05:32:14 UTC, Era Scarecrow wrote:

>  Any systems that implement a carry flag likely works exactly 
> like that.

Yes, but that misses the actual problem!

The problem isn't the _system_, it's the _compiler_.

If the language says overflow or underflow are undefined
behavior, then what the system does _doesn't matter one bit_,
because the compiler can optimize away the code entirely:
http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html


More information about the Digitalmars-d mailing list