The following code defines a derived type, t2, in terms of another derived type, t1. If an array of type t2 is allocated and values assigned, the intrinsic functions Sum and MaxVal return incorrect values (and my guess is that MinVal and possibly some other functions will have similar problems).
Module m
Type t1
Integer :: n
Real :: r
End Type t1
Type t2
Type(t1) :: tt
End Type t2
!
Type(t2), Dimension(:), Allocatable :: at2
End Module m
Program p
Use m, Only: at2
Integer :: n = 5
Integer :: i
!
Allocate (at2(n))
Do i = 1, n
at2(i)%tt%r = 99.0
at2(i)%tt%n = 2
End Do
Print*, at2(:)%tt%n
Print*, MaxVal(at2(:)%tt%n)
Print*, Sum(at2(:)%tt%n)
End Program p