Ada, HCSS and more

bearophile bearophileHUGS at lycos.com
Sat Oct 29 18:39:41 PDT 2011


bcs:

> Regarding integer overflow problems:
> http://blog.regehr.org/archives/598

Very nice paper, thank you for the link. I presume this paper nicely kicks ass of plenty of C-style programmers. It gives experimental findings in performance reduction, explains the kinds of bugs, and shows some common ones found both in benchmarks and real world code.

The paper shows that unsigned wrap-arounds too are often bugs, but suggests to offer the programmer ways to tell the compiler when a specific unsigned wrap-around in the code is acceptable and correct.

Nowadays you can't say your language has a high regard for code correctness if it fails to address such problems in a systematic and built-in way.

The paper misses to underline one point, because it only has tested already developed and debugged code. Despite the presence of overflow bugs in such debugged code, in my opinion their presence is more common in exploratory coding. When I am writing code to test an hypothesis, often I don't know what the result will be, and in such cases often I don't know how big various numbers in the program will become. In such situations overflow tests in Delphi code are precious to tell apart bogus results produced by overflows, and a bit more likely results. (Exploratory coding is probably more often done in languages like Mathematica or Python that have multi-precision integers on default, that avoid this problem too).

Bye,
bearophile


More information about the Digitalmars-d mailing list