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

ASSOCIATED bug with polymorphic pointers?

OP1
New Contributor III
706 Views

Take a look at the code below. The latest ifort (2021.13.0) and ifx (2024.2.0) do not behave consistently (and I believe that ifort may be correct here):

PROGRAM P
IMPLICIT NONE

TYPE :: T_T1
END TYPE T_T1
TYPE(T_T1), POINTER :: P1_TYPE => NULL()
CLASS(T_T1), POINTER :: P1_CLASS => NULL()

P1_CLASS => P1_TYPE
WRITE(*, *) ASSOCIATED(P1_CLASS)  ! Latest ifx returns T (incorrect)
                                  ! Latest ifort returns F (correct)

END PROGRAM P
 
0 Kudos
4 Replies
FortranFan
Honored Contributor III
666 Views

For whatever it's worth, I find the program response using IFORT to conform to the standard.  The response using IFX does not.

0 Kudos
Ron_Green
Moderator
655 Views

@OP1 @FortranFan agreed, this is a bug.  I will open a bug report with the slightly modified example:

 

PROGRAM P
IMPLICIT NONE

TYPE :: T_T1
END TYPE T_T1
TYPE(T_T1), POINTER :: P1_TYPE => NULL()
CLASS(T_T1), POINTER :: P1_CLASS => NULL()

P1_CLASS => P1_TYPE

WRITE(*, *) 'P1_CLASS => P1_TYPE !after this assigment we see...'
WRITE(*, *) 'P1_TYPE  pointer associated status is: ',ASSOCIATED(P1_TYPE)
WRITE(*, *) 'P1_CLASS pointer associated status is: ',ASSOCIATED(P1_CLASS)  
! Latest ifx returns T (incorrect)
! Latest ifort returns F (correct)

END PROGRAM P
Ron_Green
Moderator
641 Views

Bug ID is CMPLRLLVM-59976

0 Kudos
Ron_Green
Moderator
248 Views

we checking in a fix for this in our dev branch, so we will see this fix in the 2025.1.0 Update in March 2025 timeframe.

Reply