J3/05-285r1 Date: 2005/11/11 To: J3 From: Malcolm Cohen Subject: Interp request on default init for PDTs NUMBER: F03/0072 TITLE: Default initialization for "automatic" components. KEYWORDS: Parameterized Derived Type, Default Initialization. DEFECT TYPE: Erratum STATUS: J3 consideration in progress QUESTION: Consider TYPE t(len) INTEGER,LEN :: len CHARACTER(len) :: cvalue = "xyz" END TYPE SUBROUTINE s(n) TYPE(t(n)) x ... TYPE t2(len2) TYPE(t(len2)) :: tvalue = t(10,"fred nurke") END TYPE SUBROUTINE s2(n) TYPE(t(n)) :: y ... The type definition for T appears to conform to the standard; it allows an "automatic" component to be default initialized. However, the declaration of the local variable X in subroutine S will initialize the component differently depending on the value of N, for example, giving the CVALUE component the value "", "x", "xy", "xyz", "xyz " for N being 0, 1, 2, 3, 4 respectively. Q1. Was it intended that "automatic" components can be default-initialized? If the answer is "Yes", the type definition for T2 also appears to conform to the standard. However, the declaration of Y in S2 will not work if N has any value other than 10 at run time. This is surprising; there appears to be no other situation where the runtime value of a length type parameter can render a declaration invalid. Is this situation intentional? ANSWER: Q1. No, this was not intended. An edit is supplied to fix this. Q2. Not applicable. EDITS: In 4.5.3 Components, immediately before R445 , insert a new constraint: [50:40+] "C447a If appears, every type parameter and array bound of the component shall be an initialization expression." SUBMITTED BY: Malcolm Cohen HISTORY: J3/05-285 m174 Submitted J3/05-285r1 m174 Revised edit.