Apparently unsigned types really are necessary

Era Scarecrow rtcvb32 at yahoo.com
Sun Jan 22 02:46:36 PST 2012


> Would it be sane to add integer overflow/carry runtime checks in
> -debug builds? This could probably solve such issues, but we'd need
> some means to avoid this checks when necessary.

 I have asked before regarding getting some standard way to hold these values after an arithmetic operation. Comes down to problems making it portable (basically). Being as these are taken directly out of C's view of how to handle arithmetic (Which ignores the hardware's obvious view) we need to look at it twice.

 First, normal computations where we ask for a squared value, or something for a project we are working on that needs a good value. These are situations where overflow, carry, and where such effects would screw with our results. These should have checks.

 The second is algorithms, PRNGs, encryption, checksums, which rely on the behavior as it is.

 We would need a way to specify which ints needed to be checked; Or if you want to go the other direction, specify which ones specifically don't. I think having the checks in the debug mode would be wonderful, for when you need it. 

 It almost seems more likely a new struct type would be made that does those checks for you and is replaced during release with it's emulated type (Not too unlike SafeInt Microsoft was making).


More information about the Digitalmars-d mailing list