[M3devel] integer overflow
Mika Nystrom
mika at async.async.caltech.edu
Tue Jan 12 21:27:06 CET 2010
Jay K writes:
>
>Range checking and overflow checking I think are different.
>=20
>=20
>TYPE T1 =3D [1..6]=3B
>a:T1 :=3D 7=3B (* range check error *)
>b:T1 :=3D 6=3B
>c:T1 :=3D 1=3B
>d:T1 :=3D b + c=3B (* range check error *)
>e:T1 :=3D c - b=3B (* range check error *)
>f:ARRAY [1..4] OF INTEGER=3B
>f[b] :=3D 0=3B (* range check error *)
>g:INTEGER :=3D LAST(INTEGER) - 5 + a=3B (* overflow *)
>=20
>=20
>But anyway=2C yes it will be slower=2C but I believe it should be mandatory=
>=2C at least in safe modules=2C it is needed for safety=2C and I doubt it'l=
>l be *noticably* slower for the vast majority of code.
>=20
>=20
>Initially it'll probably be a command line option or such.
>=20
>=20
>Or maybe it isn't a safety issue?
>As long as one has checks on array indexing? Which I'm sure we do.
That was my point. It shouldn't be a safety issue. It's orthogonal to the
Modula-3 definition of UNSAFE.
Mika
More information about the M3devel
mailing list