Discussion:
Extra integer range checking would be nice.
(too old to reply)
Skybuck Flying
2011-07-06 04:43:42 UTC
Permalink
byte := word;
word := longword;
integer := int64;

^ all these assignments are allowed without a warninng.

Therefore these pieces of code are potential bugs which will show up only
later under more extreme circumstances.

Combinations of extreme circumstances are also possible for example with
overloaded functions and the programmer believing that the correct type is
being used while in reality some else could cause the wrong overloaded
function to be used.

These are extreem circumstances but also require extreme debugging
skills/programs ;)

Therefore I suggest that at least the compiler gets special options which
can be enabled for:

"extra range checking" and "warn for potential precision loss or overflowed
assignments".

Something like that...

Bye,
Skybuck.
Skybuck Flying
2011-07-06 04:51:17 UTC
Permalink
It's also highly likely that these range errors will go unnoticed in release
versions, since for speed reasons it's wise to turn off "range and overflow"
checking, thus these assignments would just wrap around in released
programs, causing potential corruption and such without any alarm bells
going off ! ;)

Bye,
Skybuck.

Loading...