Version 1.7 of ais/ai-00139.txt
!standard B.3.1 (36) 99-08-31 AI95-00139/03
!class ramification 96-07-24
!status Corrigendum 2000 99-06-02
!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
!qualifier Clarification
!subject Interfaces.C.Strings.Value raises Constraint_Error when Length is 0
!summary
A call to Interfaces.C.Strings.Value with Length 0, as in:
Value(Item => X, Length => 0)
raises Constraint_Error.
!question
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
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 standard 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.
!corrigendum B.03.01(36)
Replace the paragraph:
If Item = Null_Ptr then Value(Item) propagates Dereference_Error.
Otherwise 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.
by:
If Item = Null_Ptr, then Value propagates Dereference_Error.
Otherwise, Value returns the shorter of two arrays, either the first Length
chars pointed to by Item, or Value(Item). The lower bound of the result is 0.
If Length is 0, then Value propagates Constraint_Error.
!ACATS test
A test case was added to existing ACATS test CXB3010 to check Length = 0
raises Constraint_Error.
!appendix
!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>>
!discussion
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
0?
****************************************************************
Questions? Ask the ACAA Technical Agent