The upper bound of STRING concatenation is POSITIVE'LAST AI00346/01 1
910925 co WI
 !standard 04.05.03 (06) 910925 AI00346/01
 !class confirmation 850618 (provisional classification)
 !status workitem 900518
 !status received 850618
 !topic The upper bound of STRING concatenation is POSITIVE'LAST

 !summary 910925 (DRAFT)

 CONSTRAINT_ERROR is raised when catenating STRINGs if the upper bound of the
 result would exceed POSITIVE'LAST.

 !question 910925 (DRAFT)

 Consider the following example:

 procedure CAT is
 S8 : STRING(1..8);
 S3 : STRING(1..3);
 begin
 S8 := "12345678";
 S3 := S(7..8) & 'a';  is CONSTRAINT_ERROR raised? (no)
 end CAT;

 4.5.3(6) says for catenation:

 CONSTRAINT_ERROR is raised if the upper bound of the result exceeds
 the range of the index subtype, unless the result is a null array.

 Because the range of the catenated result is 7..9, which exceeds the upper
 bound of S's index constraint, is CONSTRAINT_ERROR raised?

 !response 910925 (DRAFT)

 3.6(5) says:

 The INDEX SUBTYPE for a given index position is, by definition, the
 subtype denoted by the type mark of the corresponding index subtype
 definition.

 3.6(2) defines index subtype definition:

 index_subtype_definition ::= type_mark range <>

 Since the predefined type STRING is declared in C(17) as:

 type STRING is array (POSITIVE range <>) of CHARACTER;

 the index subtype for objects of type STRING is POSITIVE. Hence, regardless
 of the actual constraint on a string variable, CONSTRAINT_ERROR is raised
 only if the upper bound of the result would exceed POSITIVE'LAST. In the
 example above, the upper bound of the result is 9, which presumably is less
than POSITIVE'LAST, so no CONSTRAINT_ERROR is raised by the catenation.
DRAFT DRAFT DRAFT
The upper bound of STRING concatenation is POSITIVE'LAST AI00346/01 2
910925 co WI
 When an index constraint is given in a type declaration, then the index
 subtype and the index constraint are the same (see 3.6(7)). For example:

 type ARR is array (1..10) of CHARACTER;

 The index subtype of ARR is INTEGER'(1) .. INTEGER'(10), and so is the
constraint.
!appendix 850617
*****************************************************************************
!section 04.05.03 (06) Japanese comments on DP8652 850510 8300561
!version 1983
!topic CONSTRAINT_ERROR raised by catenation
The 6th paragraph of 4.5.3 says "the exception CONSTRAINT_ERROR is
raised by catenation if the upper bound of the result exceeds the range
of the index subtype, unless the result is a null array.
See the following example.
#1 procedure CAT is
#2 S : STRING(1..8);
#3 SS : STRING(1..3);
#4 begin
#5 S := "12345678";
#6 SS := S(7..8) & 'a';
#7 end CAT;
(1) CONSTRAINT_ERROR should not be raised at line #6. Because the index
range of the result of & is 7..9 and 9 does not exceed POSITIVE'LAST,
which is the upper bound of the index range of type STRING.
Is this true?
(2) CONSTRAINT_ERROR should be raised at line #6. Because 9 exceeds the
upper bound of the discrete range (1..8) of the indexconstraint of S,
which is the left operand of &. Is this false?
*****************************************************************************
!section 04.05.03 (06) J. Goodenough 850617 8300567
!version 1983
!topic re: CONSTRAINT_ERROR raised by catenation
!reference 8300561
The analysis proposed in the comment is correct. CONSTRAINT_ERROR must not be
raised at line 6. 4.5.3(6) says "CONSTRAINT_ERROR is raised if the upper bound
DRAFT DRAFT DRAFT
The upper bound of STRING concatenation is POSITIVE'LAST AI00346/01 3
910925 co WI
of the result exceeds the range of the index subtype, unless the result is a
null array." SS's index subtype is POSITIVE, since that is the index subtype
of STRING, which is SS's base type. (See the definition of index subtype in
3.6(5).)
DRAFT DRAFT DRAFT