J3/04-323r1 Date: 10th August 2004 To: J3 From: Malcolm Cohen Subject: Type-bound procedures and undefined association status The following interp request from 04-323 has been modified to (a) make the question valid (b) propose two slightly different answers (straw vote?) /INTERP subgroup recommends answer 1. NUMBER: TITLE: Type-bound procedures and undefined association status KEYWORDS: Type-bound procedure, dynamic type DEFECT TYPE: Erratum STATUS: J3 consideration in progress QUESTION: It appears that the dynamic type is undefined for a pointer with undefined association status. This impacts type-bound procedures. Consider the following program. program undefined type :: t contains procedure, nopass :: nondeferred_proc => sub end type t type, extends(t) :: t2 contains procedure, nopass :: nondeferred_proc => sub2 end type t2 class(t), pointer :: x call x%nondeferred_proc contains subroutine sub write (*,*) 'Hello.' end subroutine sub subroutine sub2 write (*,*) 'Goodbye.' end subroutine sub2 end program defer Is this a valid program? If not, what restriction of the standard does it violate? If so, what does it print. Note that x%nondeferred_proc does not require the value of x (4.5.7) and thus is not a reference to x (2.5.6). Therefore, [83:23-24] does not prohibit this. If x were disassociated, its dynamic type would be t and the interpretation of this would be reasonably clear. However, the standard does not appear to specify the dynamic type of x when its association status is undefined. Nor can I find any prohibition that applies to this case. ANSWER 1: No, the program is not valid, because the standard does not establish an interpretation of it. An edit is supplied to clarify this. Furthermore, the case with a disassociated pointer was not intended to be valid. An edit is supplied to correct this oversight. ANSWER 2: No, the program is not valid, because the standard does not establish an interpretation of it. An edit is supplied to clarify this. DISCUSSION (for answer 1 only): Access to object-bound procedures (a.k.a. procedure pointer components) always require there to be an object. Access to type-bound procedures of an object was intended to require this too, but the effect of the NOPASS attribute on this was overlooked. EDITS 1: [266:24+] Insert new constraint "C1224a (R1219) If is a pointer, it shall be associated. If is allocatable, it shall be allocated." EDITS 2: [266:24+] Insert new constraint "C1224a (R1219) If is a pointer, it shall not have a pointer association status of undefined." SUBMITTED BY: Richard Maine HISTORY: J3/04-323 m169 Submitted J3/04-323r1 m169 Revised, answer proposed.