J3/13-204 To: J3 From: Van Snyder Subject: Interp concerning mixed-kind character assignment Date: 2013 December 07 ---------------------------------------------------------------------- NUMBER: F08/0087 TITLE: Mixed-kind character assignment KEYWORDS: Mixed kind, character assignment DEFECT TYPE: Erratum STATUS: Under J3 consideration QUESTION: Assuming that a Fortran 95 processor supported ISO 10646 kind, A Fortran 95 program might have included a defined assignment with arguments of character type, with the first argument of ISO 10646 kind (if the processor supported it as a nonstandard extension) and the second argument of default kind, e.g. module CHAR interface ASSIGNMENT ( = ) module procedure CHAR_ASG end interface integer, parameter :: ISO_10646 = 42 ! KIND for ISO 10646 character contains subroutine CHAR_ASG ( A, B ) character(kind=iso_10646,len=*), intent(out) :: A character(len=*), intent(in) :: B integer :: I do i = 1, min(len(a),len(b)) a(i:i) = achar(iachar(b(i:i)),kind=k) end do do i = min(len(a),len(b))+1, len(a) a(i:i) = achar(iachar(' '), kind=k) end do end subroutine CHAR_ASG end module CHAR In Fortran 2003, intrinsic assignment for character type allows the to be of ISO 10646 kind and the to be of ASCII kind. The requirements for defined assignment in subclause 12.3.2.1.2 of the 2003 standard, and 12.4.3.4.3 of the 2008 standard, require that the "arguments shall not conform as specified in Table 7.8." The example module therefore does not conform to either the 2003 or 2008 standard. There is nothing in subclause 1.6 of either the 2003 or 2008 standard to indicate that the above module would no longer conform. Was it intended that this module no longer conform? ANSWER 1 It was intended that this module no longer conform. Edits to subclause 1.6.3 of the 2008 standard are provided to clarify this. ANSWER 2 It was intended that this module continue to conform. Edits to subclause of 12.4.3.4.3 are provided to allow this module to conform. EDITS 1 Add a list item within subclause 1.6.3 "Fortran 95 compatibility" [24:27+]: o ISO/IEC 1539-1:1997 prohibited mixed-kind intrinsic character assignment. Subclause 7.5.1.6 allowed to define assignment for characters with different kind type parameter values. This standard defines intrinsic assignment for characters if is of ASCII or default kind and is of ISO 10646 kind. Subclause 12.4.3.4.3 of this standard prohibits a program to define assignment in this case." EDITS 2 Within subclause 12.4.3.4.3p2 [285:2-3], replace "the declared ... derived type" with "or the arguments shall neither both be of numeric type nor both be of logical type. If the arguments are both of character type, their kind type parameter values shall differ." {The second sentence of the replacement is necessary to prevent infinite recursion.} SUBMITTED BY: Van Snyder HISTORY: 13-204 m200 F08/0087 submitted ----------------------------------------------------------------------