comp.lang.ada
 help / color / mirror / Atom feed
From: Peter Amey <peter.amey@praxis-cs.co.uk>
Subject: Re: Optimizing Boundary Checks
Date: Fri, 13 Jun 2003 14:33:39 +0100
Date: 2003-06-13T14:33:39+01:00	[thread overview]
Message-ID: <3EE9D2B3.5050406@praxis-cs.co.uk> (raw)
In-Reply-To: slrnbeji0e.in.randhol+abuse@kiuk0152.chembio.ntnu.no

[snip]
>>
>>How is it if Index_Range was defined as a subtype of Integer?
> 
> 
> Reason for asking is that I get:
> 
> t.adb:10:11: warning: value not in range of subtype of "Standard.integer" defined at line 6
> t.adb:10:11: warning: "constraint_error" will be raised at run time
> 
> if I do:
> 
>    type Items is array (1 .. 10) of Natural;
>    Boxes : Items;
> 
> begin
>    
>    Boxes(11) := 1;
> 
> 

Your array declaration declares an index subtype just as if you had done 
so explicitly with

subtype ItemRange is Integer range 1 ..10;
type Items is array (ItemRange) of Natural;

The array index in your "Boxes..." statement must be in the array index 
subtype and Gnat correctly reports that it isn't.  Gnat can't tell you 
the name of the subtype because you didn't give it one!  This is another 
reason why it is best to avoid use of anonymous types.

Peter




  parent reply	other threads:[~2003-06-13 13:33 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-13 11:49 Optimizing Boundary Checks Preben Randhol
2003-06-13 12:03 ` Erlo Haugen
2003-06-13 12:38   ` Vinzent Hoefler
2003-06-13 12:47     ` Preben Randhol
2003-06-13 13:28       ` Vinzent Hoefler
2003-06-13 12:42   ` Preben Randhol
2003-06-13 12:48     ` Preben Randhol
2003-06-13 13:28       ` Vinzent Hoefler
2003-06-13 13:56         ` Preben Randhol
2003-06-13 14:42           ` Vinzent Hoefler
2003-06-13 15:25             ` Preben Randhol
2003-06-13 15:34               ` Vinzent Hoefler
2003-06-14 10:45                 ` Preben Randhol
2003-06-14 14:59                   ` James Rogers
2003-06-13 13:33       ` Peter Amey [this message]
2003-06-13 13:34 ` Martin Dowie
2003-06-13 13:48   ` Vinzent Hoefler
2003-06-13 14:37     ` Martin Dowie
2003-06-13 15:12       ` Vinzent Hoefler
2003-06-14  2:01         ` Jeffrey Carter
2003-06-16 11:23           ` Vinzent Hoefler
2003-06-14  8:34         ` Dmitry A. Kazakov
2003-06-14 17:20         ` Robert I. Eachus
2003-06-16 11:23           ` Vinzent Hoefler
2003-06-18 20:58             ` Brian Gaffney
2003-06-13 13:45 ` Dale Stanbrough
replies disabled

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