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

ASSOCIATED bug with polymorphic pointers?

OP1
New Contributor III
1,140 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
5 Replies
FortranFan
Honored Contributor III
1,100 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
1,089 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
1,075 Views

Bug ID is CMPLRLLVM-59976

0 Kudos
Ron_Green
Moderator
682 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.

Ron_Green
Moderator
367 Views

The fix was released with the 2025.1.0 update.

0 Kudos
Reply