TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy


Options: Use Classic View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
"Panfil, Thomas A" <[log in to unmask]>
Wed, 7 Nov 2001 14:06:53 -0500
text/plain (44 lines)
Rick Duley wrote: Tuesday, November 06, 2001 10:49 PM

> Hi teamers,


> The idea was that I could increment an integer variable past
> Integer'Last and trap the ensuing uproar, doing something
> useful with it without crashing the program.
> Well, ...that was the idea :(
> I am using GNAT 3.13p -- is this a problem with the compiler
> or have I misunderstood the purpose of CONSTRAINT_ERROR all
> these years?  Do I have to do a manual check for run-time
> errors like this or  ......

I think that you set the deep thinkers off onto a sidetrack
here, though it is an interesting and important sidetrack.

Consider the arithmetic in the following disconnected snips
from the sample program:

        --  integer value (Integer'Last) is 2,147,486,647

      Start    : constant Integer := 2_147_483_600;

      for Count in 1 .. 100 loop

            Current : Integer := Start + Count;
                        -- once the value of Count exceeds 47 this
                        --  assignment should (IMHO) raise
                        --  CONSTRAINT_ERROR and drive the point of
                        --  control into the exception handler

The fun should start when Count exceeds 3047, but it never
exceeds 100,  so no fun!! :-(

Tom Panfil -- Baltimore SIGAda