J3/04-336 Date: 10 June 2004 To: J3 From: Rob James Subject: Allocating objects of abstract types NUMBER: TITLE: Allocating objects of abstract types KEYWORDS: ALLOCATE, ABSTRACT DEFECT TYPE: STATUS: J3 consideration in progress QUESTION: Question 1 ---------- Consider the following code: module m type, abstract :: t integer :: i end type class(t), allocatable :: d end module program foo use m allocate(d) end One cannot declare a non-polymorphic object of an abstract type. Similarly, a polymorphic object should not be allocated with a dynamic type that is abstract. A in an allocate statement cannot specify an abstract type. But the effect of the allocate statement in the example above is the same as if a specifying an abstract type appeared in the allocate statement, which would not be standard-conforming. Was this example intended to be standard-conforming? Question 2 ---------- Consider the following code: module m type, abstract :: t integer :: i end type type, extends(t) :: t2 integer :: j end type class(t), allocatable :: d type(t2) :: d2 = t2(1, 2) end module program foo use m allocate(d, source=d2%t) end Similarly to the example in question 1, the allocate statement is allocating an object of a dynamic type that is abstract. Was this example intended to be standard-conforming? ANSWER: No, neither of these examples were intended to be standard-conforming. Edits are provided to correct these oversights. EDITS: All edits refer to 04-007. [111:12+] Add the following constraint: C625.1 (R623) If any has a declared type that is abstract, either or SOURCE= shall apear. [111:23+] Add the following constraint: C632.1 (R624) The shall not have a dynamic type that is abstract. SUBMITTED BY: Rob James HISTORY: 04-336 m169 Submitted