Version of ais/ai-00139.txt

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

!standard B.3.1 (36)          96-07-24 AI95-00139/02
!class ramification 96-07-24
!status WG9 approved 96-12-07
!status ARG approved 8-0-0 96-06-17
!status work item 96-05-08
!status received 96-05-07
!priority Medium
!difficulty Easy
!subject Interfaces.C.Strings.Value Raises Constraint_Error when Length is 0
!summary 96-05-08
A call to Interfaces.C.Strings.Value with Length 0, as in:
Value(Item => X, Length => 0)
raises Constraint_Error.
!question 96-05-08
B.3.1(36) says, "The lower bound of the result is 0." What happens if the Length is also 0, so that there is no possible upper bound?
!response 96-05-08
Any attempt to create a null array of type char_array, whose lower bound is 0, will clearly raise Constraint_Error. Therefore, "Value(Item => X, Length => 0)" will raise Constraint_Error. (The RM should have made this more explicit, however.)
Note that this is not harmful, since type char_array is supposed to represent a nul-terminated string, and so should not normally be of zero length.

!section B.3.1(36)
!subject Value returned by Interfaces.C.Strings.Value when Length is 0
!reference RM95 B.3.1(36)
!from Pascal Leroy 96-04-29
!reference 96-5528.b Pascal Leroy 96-4-29>>

The referenced paragraph says that "Value returns the shorter of two arrays:
the first Length chars pointed to by Item, and Value (Item).  The lower bound
of the result is 0."

This definition is fine as long as Length is positive.  However, when Length
is 0, it is unclear how one can build a char_array of length 0 whose lower
bound is 0.  (Remember, char_array is indexed by a modular type.)

Is it acceptable to return an array with positive lower bound when Length is


Questions? Ask the ACAA Technical Agent