ow Integers Should Work

bearophile bearophileHUGS at lycos.com
Mon Dec 5 19:03:45 PST 2011


Don:

> The "overflow12.pdf" paper on that site shows statistics that overflow 
> is very often intentional.

In C/C++ code, but we are developing D, a new language that hopes to fix some of the mistakes of languages invented lot of time ago.


> It's strong evidence that you *cannot* make signed overflow an error.

In C/C++ code, maybe, yet they suggest to invent better tools to find overflow in C/C++ programs too.

In better/modern languages signed overflow is correct only in the precise points where it is required. The overflow (for signed) or wraparound (for unsigned) has not to be the default behaviour, because it's crappy and often leads to bugs.


>  Even if you could do it with zero complexity 
> and zero performance impact, it would be wrong.

In C/C++, maybe. But not in D/Ada/Delphi/Haskell/etc.

Bye,
bearophile


More information about the Digitalmars-d mailing list