Pure, Nothrow in Generic Programming

bearophile bearophileHUGS at lycos.com
Fri Nov 27 13:52:08 PST 2009


Denis Koroskin:

> I don't think integer overflow could be considered an undefined behavior.  
> It's pretty much expected that uint.max + 1 == 0.

Computers are (mostly) deterministic, so in a certain sense everything they do can be expected :-)
But sometimes the programmer "forgets" or doesn't take into account that a number can be int.max, so the overflow can be unexpected for him/her.
The same can be said for array bounds, the expected that a write past the array end will give troubles, but having bound tests is often useful anyway, because it helps catch programming errors, etc.

Bye,
bearophile



More information about the Digitalmars-d mailing list