gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gm2] no overflow checking ?


From: Arnauld Michelizza
Subject: [Gm2] no overflow checking ?
Date: Wed, 20 Apr 2011 10:07:29 +0200

Hi guys,

while learning modula-2, I wanted to test how binaries compiled with
gm2 deals with overflows.
As I understood, modula-2 strengh is that it can prevent overflows
(integer-, buffer-, heap-) with runtime bounds checking.
However, I didn't found how to do that with gm2. For example, here is
a very short program that add 2 values :

----- [code] -----
VAR
        x, y, res : INTEGER;
BEGIN
        WriteString("x> ");
        ReadInt(x);

        WriteString("y> ");
        ReadInt(y);

        res := x + y;
        WriteString("x+y> ");
        WriteInt(res, 1);
        WriteLn();

END test.
----- [code] -----

And here is the integer overflow :

  am$ ./a.out
   x> 2147483647
  y> 1
  x+y> -2147483648

I think I missed something....
Any help ?

Arnauld



reply via email to

[Prev in Thread] Current Thread [Next in Thread]