From: anon@anon.org (anon)
Subject: Re: unsigned type
Date: Sat, 04 Jul 2009 09:09:50 GMT
Date: 2009-07-04T09:09:50+00:00 [thread overview]
Message-ID: <y%E3m.418422$4m1.31580@bgtnsc05-news.ops.worldnet.att.net> (raw)
In-Reply-To: 4a4e7705$0$31863$9b4e6d93@newsspool3.arcor-online.net
A String literal is define in RM 4.2 ( 4, 11 ) with the String
type defined in RM 3.6.3 ( 4 ) and its index type (Positive) is define
in RM 3.6.3 ( 3 ) and RM 3.5.4 ( 13 ). With the Positive base range
being Natural defined by RM 3.5.4 ( 13..14 ).
So to create a "null range" Strings aka a null String literal, the type and
range must be check! In the following hierarchical outline, based on RM 3.2:
1. RM 4.2 ( 11 ) : Check if Lower bound > Base_Range'First.
(Lower bound must be a member of the "subtype"
or Base_Range type in order to preform the
comparison, so Lower Bound type is checked)
2. RM 3.6.1 ( 4 ) : Check if both indexes values are within subtype
or range type.
(Upper bound is now verified to be a valid
type of the range)
3. RM 3.5 : Check if Lower bounds > Upper bounds
(verify the "null range" definition)
4. Else it is not a valid null range String and a Constraint_Error
will be raised.
So, is "A : String ( 1..0 )" legal.
Yes maybe! Yes, because RM 4.2 ( 11 ) states that "for the evaluation of
a null string literal, a check is made that its lower bound is greater
than the lower bound of the base range of the index type. And the Lower
bound ( 1 ) > ( 0 ) aka Natural'First which fills the definition in
RM 4.2 ( 11 ). And the Lower bound ( 1 ) > Upper bound ( 0 ) RM 3.5 ( 4 ).
But there is a problem from RM 3.6.1 ( 4 ) it states that both indexes must
be a member of the subtype for the arrays range. Since, Strings are just a
predefined one-dimensional character array using Positives as indexes. That
means for a String that both indexes must be a member of the Positive type
making the ( 1..0 ) invalid, since 0 is not define as a Positive type. So,
from RM 3.6.1 ( 4 ) this null range String is not valid.
Now, is "B : String := ( -5 .. -7 => ' ' ) ;" legal?
First, it violates RM 4.2 ( 11 ), that is, the lower bound ( -5 ) is not
greater than the lower bound of the base range of the index type
Natural aka Natural'First or 0. So, from RM 4.2 ( 11 ) this should raise
a Constraint_Error. But it does not!
And then both indexes are not valid members of either the index type
Positive or even its base range type aka Natural. So, from RM 3.6.1 ( 4 )
this is an error.
But, it does comply with the "null range" in RM 3.5 ( 4 ), where the
lower bounds must be greater than upper bounds, but that does not
replace the other two requirements, for a null String literal.
So, this should raise a Constraint_Error.
In <4a4e7705$0$31863$9b4e6d93@newsspool3.arcor-online.net>, Georg Bauhaus <rm.tsoh.plus-bug.bauhaus@maps.futureapps.de> writes:
>anon wrote:
>
>> Since the RM does not directly
>> give one permission to use an illegal index value, then one should assume
>> that all index must be valid before checking for a null array.
>
>To "assume" formal properties like index validity seems inadequate:
>this is about index ranges, not index values, and about what the RM
>has to say about the formal notion of a "null range" (as has now been
>said many times).
>
>> Actually,
>> Ada RM 0 ( 29 ) states that it is illegal and the program shall create
>> an exception if the program "access an array component by using an
>> incorrect index value".
>
>There isn't any access to an array component through a null range.
>For indexing an array component, one must have an index value.
>There is no value in a null range. Therefore, there is no
>access to an array component.
>
>
>> Also, a number of ACATS test suggest this as well
>> and the program below will illustrate this. With that stated from the RM
>> the program shall
>>
>> if S'First in S'Range and then S'Last in S'Range then
>> if S'First <= S'Last then
>> -- access/create an array bound by ( S'First .. S'Last )
>> else
>> -- return a null created array access
>> end if ;
>> else
>> raise Constraint_Error ;
>> end if ;
>>
>> You have to look at the whole RM to find out if there are other sections
>> that may clarify a statements or allow an exception. But there is no
>> RM rules that allows an out of bounds index to be used.
>
>Maybe the verse and illustrations given by J.-P. Rosen and
>Adam Beneschan have slipped: There are RM rules regarding
>null ranges. The construct "Greater .. Smaller" as used in, say,
>initializing a null string refers to null ranges, so not to any
>index value at all.
>
next prev parent reply other threads:[~2009-07-04 9:09 UTC|newest]
Thread overview: 113+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-28 15:36 unsigned type Rob Solomon
2009-06-28 15:45 ` Florian Weimer
2009-06-28 15:48 ` Albrecht Käfer
2009-06-28 17:56 ` anon
2009-06-28 19:17 ` Ludovic Brenta
2009-06-28 23:08 ` anon
2009-06-29 0:19 ` tmoran
2009-06-29 8:00 ` anon
2009-06-29 9:56 ` Jean-Pierre Rosen
2009-06-29 10:21 ` Ludovic Brenta
2009-06-29 11:23 ` sjw
2009-06-29 12:07 ` Jean-Pierre Rosen
2009-06-29 20:06 ` anon
2009-06-29 19:31 ` anon
2009-06-29 21:49 ` Georg Bauhaus
[not found] ` <zuKdneNYxfFNLNTXnZ2dnUVZ_t2dnZ2d@earthlink.com>
2009-06-30 11:29 ` anon
2009-06-30 12:19 ` Ludovic Brenta
2009-06-29 20:19 ` anon
2009-06-29 20:41 ` Ludovic Brenta
2009-06-29 22:15 ` Georg Bauhaus
2009-06-29 23:08 ` Adam Beneschan
2009-06-29 23:11 ` Adam Beneschan
2009-06-30 12:39 ` Martin
2009-06-29 10:25 ` Georg Bauhaus
2009-06-29 20:02 ` anon
2009-06-29 22:08 ` Georg Bauhaus
2009-06-30 23:01 ` Randy Brukardt
2009-06-30 13:46 ` Jean-Pierre Rosen
2009-06-30 15:22 ` Adam Beneschan
2009-06-30 15:59 ` Albrecht Käfer
2009-06-30 16:59 ` Adam Beneschan
2009-06-30 17:44 ` Albrecht Käfer
2009-06-30 18:13 ` Robert A Duff
2009-06-30 18:16 ` Albrecht Käfer
2009-06-30 23:48 ` anon
2009-07-01 1:39 ` Adam Beneschan
2009-07-02 19:04 ` anon
2009-07-02 19:49 ` anon
2009-07-02 21:37 ` Adam Beneschan
2009-07-03 1:42 ` anon
2009-07-03 2:10 ` Adam Beneschan
2009-07-03 7:07 ` Jean-Pierre Rosen
2009-07-03 20:53 ` anon
2009-07-03 21:24 ` Georg Bauhaus
2009-07-04 9:09 ` anon [this message]
2009-07-04 13:43 ` Georg Bauhaus
2009-07-06 9:04 ` AdaMagica
2009-07-03 21:46 ` Adam Beneschan
2009-07-04 12:39 ` Martin
2009-07-01 8:09 ` Jean-Pierre Rosen
2009-07-01 15:08 ` Albrecht Käfer
2009-07-11 14:40 ` Hibou57 (Yannick Duchêne)
2009-07-11 17:18 ` sjw
2009-07-11 18:15 ` Hibou57 (Yannick Duchêne)
2009-07-11 20:20 ` anon
2009-07-12 17:57 ` Samuel Tardieu
2009-07-12 18:24 ` AdaMagica
2009-07-13 22:03 ` anon
2009-07-14 7:58 ` Martin
2009-07-16 13:54 ` anon
2009-07-16 14:41 ` Martin
2009-07-16 15:12 ` Adam Beneschan
2009-07-11 14:43 ` Hibou57 (Yannick Duchêne)
2009-07-11 15:22 ` Albrecht Käfer
2009-06-29 8:42 ` Martin
2009-06-29 8:54 ` Dmitry A. Kazakov
2009-06-29 10:10 ` Martin
2009-06-29 12:34 ` Dmitry A. Kazakov
2009-06-29 19:26 ` anon
2009-06-29 23:02 ` Martin
2009-06-29 19:47 ` anon
2009-06-30 8:31 ` Ludovic Brenta
2009-06-28 19:54 ` tmoran
2009-06-28 22:34 ` Gary Scott
2009-06-28 23:15 ` John B. Matthews
2009-06-28 23:21 ` anon
2009-06-29 7:18 ` Dmitry A. Kazakov
2009-06-29 9:52 ` Georg Bauhaus
2009-06-29 12:43 ` Dmitry A. Kazakov
2009-06-29 13:36 ` Rob Solomon
2009-06-29 14:03 ` Robert A Duff
2009-06-29 14:13 ` Georg Bauhaus
2009-06-29 14:18 ` Ludovic Brenta
2009-06-29 15:40 ` Robert A Duff
2009-07-03 1:41 ` Rob Solomon
2009-07-03 7:12 ` Learning Ada (Was: unsigned type) Jacob Sparre Andersen
2009-07-03 8:38 ` Learning Ada Peter Hermann
2009-07-03 9:44 ` Georg Bauhaus
2009-07-03 22:20 ` Learning Ada (Was: unsigned type) anon
2009-07-04 14:53 ` Georg Bauhaus
2009-07-05 23:21 ` anon
2009-07-06 0:05 ` Ludovic Brenta
2009-07-06 0:19 ` Learning Ada Albrecht Käfer
2009-07-06 2:50 ` anon
2009-07-06 6:18 ` AdaMagica
2009-07-06 7:47 ` Jean-Pierre Rosen
2009-07-06 20:21 ` anon
2009-07-06 21:08 ` Georg Bauhaus
2009-07-06 22:43 ` Frank J. Lhota
2009-07-09 22:28 ` anon
2009-07-10 6:23 ` AdaMagica
2009-07-06 10:53 ` Learning Ada (Was: unsigned type) Georg Bauhaus
2009-07-06 19:34 ` anon
2009-07-06 20:29 ` Learning Ada Albrecht Käfer
2009-07-06 21:04 ` Learning Ada (Was: unsigned type) Georg Bauhaus
2009-07-07 19:25 ` sjw
2009-07-06 23:15 ` Randy Brukardt
2009-07-07 15:29 ` Adam Beneschan
2009-07-09 0:15 ` Randy Brukardt
2009-07-09 15:26 ` Adam Beneschan
2009-06-29 15:37 ` unsigned type Adam Beneschan
2009-07-06 20:20 ` Dave
2009-06-29 16:51 ` Martin Krischik
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox