From: Lucretia <laguest9000@googlemail.com>
Subject: Re: Should exceeding the range of Integer wrap around a la C?
Date: Mon, 21 May 2018 08:57:44 -0700 (PDT)
Date: 2018-05-21T08:57:44-07:00 [thread overview]
Message-ID: <a76b2922-c2b9-4674-bd08-e310a6518cce@googlegroups.com> (raw)
In-Reply-To: <7ba47ec1-28e7-43e1-83a0-2a4d2cf0fd92@googlegroups.com>
On Monday, 21 May 2018 16:23:21 UTC+1, nrs...@gmail.com wrote:
> I expect this program to print powers of 2 until `X` exceeds the range of Integer. Instead, it seems to "wrap around" with the following (abbreviated)
> I am compiling with GNAT 4.9.2 on a Debian Linux system using `gnat make compute` with no further compiler flags. Are my expectations wrong, or is this incorrect behavior?
Your compiler is ancient, upgrade to to at least 6.4.0.
On my machine with 6.4.0, gnatmake compute, then I run it, I get this:
$ ./compute
1
2
4
8
16
32
64
128
256
512
1024
2048
4096
8192
16384
32768
65536
131072
262144
524288
1048576
2097152
4194304
8388608
16777216
33554432
67108864
134217728
268435456
536870912
1073741824
raised CONSTRAINT_ERROR : compute.adb:8 overflow check failed
I didn't even specify "-gnata -gnato -gnatE" to gnatmake as I normally would, you want those options BTW.
next prev parent reply other threads:[~2018-05-21 15:57 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-21 15:23 Should exceeding the range of Integer wrap around a la C? nrs5134
2018-05-21 15:27 ` Jacob Sparre Andersen
2018-05-21 15:45 ` Anh Vo
2018-05-21 16:46 ` Simon Wright
2018-05-21 18:47 ` Anh Vo
2018-05-21 15:57 ` Lucretia [this message]
2018-05-21 16:49 ` Simon Wright
2018-05-21 19:11 ` Paul Rubin
2018-05-22 0:39 ` Jere
2018-05-22 0:58 ` Dan'l Miller
2018-05-22 1:36 ` Paul Rubin
2018-05-21 20:43 ` nrs5134
2018-05-22 17:52 ` Björn Lundin
2018-05-22 20:11 ` nrs5134
2018-05-22 20:23 ` Björn Lundin
2018-05-23 7:35 ` Dmitry A. Kazakov
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox