(j3.2006) More on default initialization and structure constructors

Van Snyder Van.Snyder
Mon Nov 21 22:40:27 EST 2016


Suppose I have two types:

  type :: T1
    integer :: i1 = 0
  end type T1

  type, extends(t1) :: T2
    integer :: I2 = 0
  end type T2

Is t2(i2=42) a valid structure constructor, or do I need t2(t1(),i2=42)?

C492 (12-007) says "A component-spec shall be provided for a
nonallocatable component unless it has default initialization...."

If the parent type has default initialization for every component, does
the parent component have default initialization?

Suppose I have a third type

  type :: T3
    integer :: I3 = 0
    type(t2) :: V3
  end type T3

Is t3(i3=42) a valid structure constructor, or do I need
t3(i3=0,v3=t2())?

If every component of a type has default initialization, does a
component of that type (e.g. V3 in type T3 above) have default
initialization, or does it need to be explicitly given a component-spec?





More information about the J3 mailing list