[M3devel] integer overflow

hendrik at topoi.pooq.com hendrik at topoi.pooq.com
Tue Jan 12 21:37:49 CET 2010


On Tue, Jan 12, 2010 at 08:21:27PM +0000, Jay K wrote:
> 
> Range checking and overflow checking I think are different.
>  
>  
> TYPE T1 = [1..6];
> a:T1 := 7; (* range check error *)
> b:T1 := 6;
> c:T1 := 1;
> d:T1 := b + c; (* range check error *)
> e:T1 := c - b; (* range check error *)
> f:ARRAY [1..4] OF INTEGER;
> f[b] := 0; (* range check error *)
> g:INTEGER := LAST(INTEGER) - 5 + a; (* overflow *)
>  
>  
> But anyway, yes it will be slower, but I believe it should be mandatory, at least in safe modules, it is needed for safety, and I doubt it'll be *noticably* slower for the vast majority of code.
>  
>  
> Initially it'll probably be a command line option or such.
>  
>  
> Or maybe it isn't a safety issue?
> As long as one has checks on array indexing? Which I'm sure we do.

I always thought one of the points about declared ranges (instead of 
making everything just int, as C does) was to enable one to suppress 
most of the array indexing checks safely.

-- hendrik



More information about the M3devel mailing list