[M3devel] comparisons vs. subranges
hendrik at topoi.pooq.com
hendrik at topoi.pooq.com
Sat Mar 13 19:29:24 CET 2010
On Sat, Mar 13, 2010 at 10:19:21AM +0000, Jay K wrote:
>
> <*UNUSED*>PROCEDURE CardinalGE0(a:CARDINAL):BOOLEAN=BEGIN RETURN a>=0; END CardinalGE0;
> <*UNUSED*>PROCEDURE CardinalEQN1(a:CARDINAL):BOOLEAN=BEGIN RETURN a=-1; END CardinalEQN1;
>
>
>
>
> Seems to me, the front end should notice these.
>
> The first should always be TRUE.
>
> And possibly, possibly warn.
>
> The second should always be FALSE.
>
> And possibly, possibly warn.
>
>
>
> "Generic" programming often hits this sort of thing though, a good reason not to warn.
>
> Programmer might also be working with existing code and have changed INTEGER to CARDINAL.
>
> Or be defending against future maintainers changing CARDINAL to INTEGER.
Wasn't there a discussion a while ago about subranges out-of-bounds not
being a safety problem? (Or was it arithmetic overflow?) This
optimisation might well cause a quite hard-to-find bug if we don't
guarantee subrange integrity.
-- hendrik
More information about the M3devel
mailing list