It's related to allocating an allocatable component of a user-defined type array with source or mold option, I'm not sure whether this is a wrong way of using mold/source or is a known issue and will be fixed in 2017 version. Anyway, here is the example:
program main implicit none type t_test real(8), allocatable :: T(:) end type real(8) :: B(2) type(t_test) :: A(1) do allocate(A(1)%T,mold=B) !allocate(A(1)%T,source=B) enddo end program
and memory leaks!
if change "A(1)" to a scale "A", then allocate statement will raise a "allocatable array is already allocated" error. I'm not sure whether this error is normal or mold/source should reallocate automatically if shape doesn't match?
compiled with Intel(R) Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 188.8.131.52 Build 20160415
Thanks - the subsequent ALLOCATEs should cause a run-time error. The standard says, "An allocatable variable with [allocated] status may be referenced, defined, or deallocated; allocating it causes an error condition in the ALLOCATE statement." I'm not sure why that's not happening here and will send this on to the developers. Issue ID is DPD200414580.
From what I can see, if SOURCE= or MOLD= is used, no check for "already allocated" is done, which is incorrect.