Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28445 Discussions

Problem with nested ASSOCIATE constructs

MR
Beginner
352 Views

Hi,
   I get an error with the attached code which I think is due to a
problem within the compiler. The error appears when using two nested
associate constructs:

$ ifort -c test.f90
test.f90(20): error #7146: This object must not be used as an allocate-object in an allocate-stmt or deallocate-stmt in a PURE procedure or an internal procedure contained in a PURE procedure.   [VALS]
   allocate( xdt%vals( sum(ydt) ) ) ! error
-----------------^
compilation aborted for test.f90 (code 1)

Notice that all the three equivalent constructs included in the
example compile without problem, and notice that gfortran accepts also
the problemtaic version.

$ ifort -V
Intel(R) Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 15.0 Build 20140723

module m
 implicit none

 type :: t1
  integer, allocatable :: vals(:)
 end type t1

 type :: t2
  type(t1) :: dat
 end type t2

contains

 pure subroutine s(x,y)
  type(t1),         intent(in)  :: y
  type(t2), target, intent(out) :: x

   associate( xdt => x%dat  )
   associate( ydt => y%vals )
   allocate( xdt%vals( sum(ydt) ) ) ! error
   !allocate( x%dat%vals( sum(ydt) ) ) ! works
   end associate
   end associate

   ! This works
   !associate( xdt => x%dat  )
   !allocate( xdt%vals( sum(y%vals) ) )
   !end associate

   ! ... as well as this
   !associate( xdt => x%dat , ydt => y%vals )
   !allocate( xdt%vals( sum(ydt) ) )
   !end associate

 end subroutine s

end module m
0 Kudos
2 Replies
MR
Beginner
352 Views

Sorry, one correction: in my example code, the TARGET attribute of the dummy argument is not required to reproduce the problem.

Marco

0 Kudos
Kevin_D_Intel
Employee
352 Views

Thank you for reporting this error, Marco. I reported this to the Developers (see internal tracking id below) for further investigation and will let you know what I hear back.

(Internal tracking id: DPD200361889)

0 Kudos
Reply