gm2
[Top][All Lists]
Advanced

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

Re: [Gm2] no overflow checking ?


From: Gaius Mulley
Subject: Re: [Gm2] no overflow checking ?
Date: Wed, 20 Apr 2011 09:35:25 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux)

Arnauld Michelizza <address@hidden> writes:

> 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

Hi Arnauld,

this looks like a bug - I'll fix it!  Thanks for the report,

regards,
Gaius



reply via email to

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