1! { dg-do run } 2! PR 25217: INTENT(OUT) dummies of derived type with default initializers shall 3! be (re)initialized upon procedure entry, unless they are ALLOCATABLE. 4! Modified to take account of the regression, identified by Martin Tees 5! http://gcc.gnu.org/ml/fortran/2006-08/msg00276.html and fixed with 6! PR 28788. 7module dt 8 type :: drv 9 integer :: a(3) = [ 1, 2, 3 ] 10 character(3) :: s = "abc" 11 real, pointer :: p => null() 12 end type drv 13end module dt 14 15module subs 16contains 17 subroutine foo(fb) 18 use dt 19 type(drv), intent(out) :: fb 20 call sub (fb) 21 end subroutine foo 22 23 subroutine sub(fa) 24 use dt 25 type(drv), intent(out) :: fa 26 27 if (any(fa%a /= [ 1, 2, 3 ])) call abort() 28 if (fa%s /= "abc") call abort() 29 if (associated(fa%p)) call abort() 30 end subroutine sub 31end module subs 32 33program main 34 use dt 35 use subs 36 implicit none 37 type(drv) :: aa 38 type(drv), allocatable :: ab(:) 39 real, target :: x = 99, y = 999 40 41 aa = drv ([ 4, 5, 6], "def", x) 42 call sub(aa) 43 44 aa = drv ([ 7, 8, 9], "ghi", y) 45 call foo(aa) 46end program main 47 48