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

14.0 Compiler generates incorrect results

Neil_Carlson
Beginner
517 Views

Under certain circumstances, a pointer will remain associated, according to ASSOCIATED(), after it is deallocated.  I've attached a 17-line example that exhibits this incorrect behavior with the new 14.0 compiler.

[Are we not allowed to attach files anymore?]

[fortran]

!!

!! COMPILER GENERATES INCORRECT CODE

!!
!! In the following example, a derived-type scalar pointer P is allocated and
!! then deallocated. At that point, ASSOCIATED(P) should return FALSE but it
!! returns TRUE. Key to the error seems to be that the pointer is a dummy
!! argument and that the derived type contains an allocatable CLASS(*) component.
!!
!! $ ifort --version
!! ifort (IFORT) 14.0.0 20130728
!!
!! $ ifort intel-bug-20131030.f90
!! $ ./a.out
!! associated(p) = T (should be FALSE)
!!

module foo_mod
type, public :: foo
class(*), allocatable :: value
end type
contains
subroutine sub (p)
type(foo), pointer :: p
allocate(p)
deallocate(p)
print *, 'associated(p) =', associated(p), '(should be FALSE)'
end subroutine
end module

program main
use foo_mod
type(foo), pointer :: p
call sub (p)
end program[/fortran]

0 Kudos
3 Replies
Neil_Carlson
Beginner
517 Views

Here's the example

0 Kudos
Kevin_D_Intel
Employee
517 Views

Thank you for reporting this issue and for the convenient reproducer. I reported it to Development (see internal tracking id below).

I found the previous 13.1 compiler produces the same result. If needed, as a work around, one can NULLIFY(p) explicitly after the deallocation.

(Internal tracking id: DPD200249493)
(Resolution Update on 09/16/2014): This defect is fixed in the Intel® Parallel Studio XE 2015 Initial Release (2015.0.090 - Linux)

0 Kudos
Kevin_D_Intel
Employee
517 Views

I confirmed this defect is fixed in our next major release (15.0 compiler) due out later this year.

0 Kudos
Reply