1! { dg-do run } 2! 3! PR 43388: [F2008][OOP] ALLOCATE with MOLD= 4! 5! Contributed by Janus Weil <janus@gcc.gnu.org> 6 7type :: t1 8 integer :: i 9end type 10 11type,extends(t1) :: t2 12 integer :: j = 4 13end type 14 15class(t1),allocatable :: x,y 16type(t2) :: z 17 18 19!!! first example (static) 20 21z%j = 5 22allocate(x,MOLD=z) 23 24select type (x) 25type is (t2) 26 print *,x%j 27 if (x%j/=4) call abort 28 x%j = 5 29class default 30 call abort() 31end select 32 33 34!!! second example (dynamic, PR 44541) 35 36allocate(y,MOLD=x) 37 38select type (y) 39type is (t2) 40 print *,y%j 41 if (y%j/=4) call abort 42class default 43 call abort() 44end select 45 46end 47