[M3devel] Integer overflow

Tony Hosking hosking at cs.purdue.edu
Sun Jan 10 05:38:42 CET 2010


One take on this is that it certainly lets you check for overflow explicitly! ;-)

On the other hand, it seems unreasonable that you could end up with a CARDINAL holding a negative value!

On 9 Jan 2010, at 23:33, Tony Hosking wrote:

> So, in my experiments with range checking on integers, I have been playing with the overflow case:
> 
> VAR s: CARDINAL := LAST(INTEGER);
> BEGIN INC(s) END;
> 
> Should this fail at runtime with a range check error?
> 
> The language definition says that integer overflow may or may not be checked, depending on the implementation.  (See FloatMode.i3).
> 
> If it is not checked, is it reasonable that s takes on the value FIRST(INTEGER)?
> 
> Antony Hosking | Associate Professor | Computer Science | Purdue University
> 305 N. University Street | West Lafayette | IN 47907 | USA
> Office +1 765 494 6001 | Mobile +1 765 427 5484
> 
> 
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20100109/abfc41b9/attachment-0002.html>


More information about the M3devel mailing list