OT (partially): about promotion of integers

Araq rumpf_a at gmx.de
Wed Dec 12 04:51:13 PST 2012


> Arithmetic in computers is different from the math you learned 
> in school. It's 2's complement, and it's best to always keep 
> that in mind when writing programs.

 From http://embed.cs.utah.edu/ioc/

" Examples of undefined integer overflows we have reported:

     An SQLite bug
     Some problems in SafeInt
     GNU MPC
     PHP
     Firefox
     GCC
     PostgreSQL
     LLVM
     Python

We also reported bugs to BIND and OpenSSL. Most of the SPEC CPU 
2006 benchmarks contain undefined overflows."

So how does D improve on C's model? If signed integers are 
required to wrap around in D (no undefined behaviour), you also 
prevent some otherwise possible optimizations (there is a reason 
it's still undefined behaviour in C).


More information about the Digitalmars-d mailing list