Version 1.3 of ais/ai-00120.txt

Unformatted version of ais/ai-00120.txt version 1.3
Other versions for file ais/ai-00120.txt

!standard 03.05.02 (03)          99-05-28 AI95-00120/05
!class confirmation 96-04-04
!status WG9 approved 98-06-12
!status ARG Approved (with changes) 10-0-0 98-04-01
!status ARG Approved (with changes) 10-0-1 97-11-16
!status work item 96-04-04
!status received 96-04-04
!priority Low
!difficulty Easy
!subject What is the minimal upper bound of type Integer?
!summary
Implementations are expected to provide predefined integer types appropriate to the architecture; these might typically be 32 bits for Integer and 64 bits for a type Long_Integer. However, a 16-bit type Integer might be appropriate for some small embedded processors.
The only formal requirement of the standard (3.5.4(21)) is that Integer shall include the range -2**15+1 .. +2**15-1." The minimal upper bound of the type Integer is therefore 32767. This corresponds to a 16-bit implementation.
The declaration of an array whose index range exceeds that of the largest supported integer type raises Constraint_Error.
!question
3.5.4 seems to indicate that an implementation is allowed to implement predefined type Integer as a 16 bit integer type.
"In an implementation, the range of Integer shall include
-2**15+1 .. +2**15-1."
However, if this is the case, what will happen for this declaration:
Full_Sequence : constant Ada.Strings.Wide_Maps.Wide_Character_Sequence := To_Sequence (not Null_Set);
By A.4.2(49) Full_Sequence is a Wide_String (array (Positive range <>) of Wide_Character) and is required to contains "each of the characters in the set represented by [not Null_Set], in ascending order."
By A.4.2(39), not Null_Set contains ALL of the Wide_Characters, that is a total of 65536 values.
Is the declaration of Full_Sequence allowed to raise Constraint_Error or is the upper bound of predefined type Integer required to be at least 65536 ?
!response
The index range of the constant Full_Sequence is 1 .. 65536. However, in an implementation where type Integer is a 16-bit type, this index range lies outside the range of the subtype Positive which is the index subtype of Full_Sequence. As a consequence, an attempt to declare the array Full_Sequence using such an implementation raises Constraint_Error.
!ACATS test
It would be possible to create a C-Test to check that the minimum upper bound of Integer is supported, and to check that examples in this issue. However, such a test would not be valuable as it is very unlikely that an implementation make either of these errors.
!appendix

!section 3.5.2(03)
!subject What is the minimal upper bound of type Integer ?
!reference RM95-3.5.2(3)
!reference RM95-3.5.4(21)
!reference RM95-A.1(41)
!reference RM95-A.4.2(39)
!reference RM95-A.4.2(49)
!reference RM95-A.4.7
!from Vincent Celier 95-11-30
!reference 95-5401.a Vincent Celier  95-11-30>>
!discussion

3.5.4 seems to indicate that an implementation is allowed to implement
prededefined type Integer as a 16 bit integer type.

  "In an implementation, the range of Integer shall include
   -2**15+1 .. +2**15-1."

However, if this is the case, what will happen for this declaration:

   Full_Sequence : constant Ada.Strings.Wide_Maps.Wide_Character_Sequence
            := To_Sequence (not Null_Set);

By A.4.2(49) Full_Sequence is a Wide_String (array (Positive range <>) of
Wide_Character) and is required to contains "each of the characters in the
set represented by [not Null_Set], in ascending order."

By A.4.2(39), not Null_Set contains ALL of the Wide_Characters, that is a
total of 65536 values.

Is the declaration of Full_Sequence allowed to raise Constraint_Error or is
the upper bound of predefined type Integer required to be at least 65536 ?
-- Vincent Celier
-- 9100 McCutcheon Place, RICHMOND, B.C., V7A 5A5, CANADA
-- e-mail: vcelier@direct.ca


****************************************************************

!section 03.05.02(03)
!subject What is the minimal upper bound of type Integer ?
!reference AI95-00120/00
!from Keith Thompson 96-06-21
!reference 96-5606.a Keith Thompson 96-6-21>>
!discussion

The response to this AI, dated 96-04-04, says:

> In an implementation where type Integer is a 16-bit type, it is likely
> that memory is quite limited.  Therefore, Storage_Error would be an
> appropriate response to the above example.

It may be likely that memory is limited but it is by no means certain.
One can easily imagine a system with plentiful memory on which it makes
sense to declare Integer as a 16-bit type.  (Some of the earlier members
of the 680x0 and x86 families might qualify.)

In this case, what happens for the declaration in question?

   Full_Sequence : constant Ada.Strings.Wide_Maps.Wide_Character_Sequence
            := To_Sequence (not Null_Set);

I suggest that raising Constraint_Error is appropriate.

****************************************************************

Questions? Ask the ACAA Technical Agent