comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adambeneschan@gmail.com>
Subject: Re: Bug or feature?
Date: Wed, 14 May 2014 14:37:47 -0700 (PDT)
Date: 2014-05-14T14:37:47-07:00	[thread overview]
Message-ID: <a6143539-a964-4ed3-bc84-557dcd562722@googlegroups.com> (raw)
In-Reply-To: <224148c3-2a31-4f3e-a3a3-0a588773798b@googlegroups.com>

On Wednesday, May 14, 2014 2:24:57 PM UTC-7, Laurent wrote:

> Modified my little test with Result:= 2_000_000_000 + 2_000_000_000;
> Doesn't compile:
> 
> /Volumes/Kingston/GPS/Chapter 14/buffer_overflow.adb
>         11:27 static expression fails Constraint_Check
>         11:27 value not in range of type "Standard.Integer"

Yes, you have to use variables.  2_000_000_000 + 2_000_000_000 is a static expression that can be computed at compile-time, and some of the checks that would normally cause exceptions at run-time will cause errors at compile-time, due to special rules in the language about static expressions.

                            
> So it is a bug?  Or just a matter of putting an additional flag?

The requirement to add -gnato to get full checking has been discussed quite a bit on this newsgroup and elsewhere.  Basically, overflow checking adds a lot of code on most processors, and I think the decision was made early on to disable it by default.  Not everyone likes this.  It looks like there's a bug in how range checking is handled if -gnato isn't used, over and above the lack of overflow checking.  But it appears to be a bug that cannot come up if -gnato is used.

                            -- Adam

  reply	other threads:[~2014-05-14 21:37 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-14 19:06 Bug or feature? Laurent
2014-05-14 19:57 ` Adam Beneschan
2014-05-14 20:15   ` Adam Beneschan
2014-05-14 21:24     ` Laurent
2014-05-14 21:37       ` Adam Beneschan [this message]
2014-05-14 22:02         ` Robert A Duff
2014-05-14 22:25           ` Adam Beneschan
2014-05-14 21:42       ` Robert A Duff
2014-05-15  8:51         ` Georg Bauhaus
2014-05-14 21:48       ` Randy Brukardt
2014-05-14 22:35         ` Robert A Duff
2014-05-15  8:23           ` Simon Wright
2014-05-15 18:21             ` Randy Brukardt
2014-05-15  8:58         ` Georg Bauhaus
2014-05-15 18:30           ` Randy Brukardt
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox