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

ICE with pointers and ASSOCIATED

OP1
New Contributor III
459 Views

The following code ICEs with both ifort 2021.13.0 and ifx 2024.2.0:

MODULE M
IMPLICIT NONE (TYPE, EXTERNAL)
TYPE :: T
    CLASS(T), POINTER :: PTR
    CONTAINS
        PROCEDURE :: GET_PTR
END TYPE T
CONTAINS
    FUNCTION GET_PTR(SELF)
    IMPLICIT NONE (TYPE, EXTERNAL)
    CLASS(T), INTENT(INOUT) :: SELF
    CLASS(T), POINTER       :: GET_PTR
    GET_PTR => SELF%PTR
    END FUNCTION GET_PTR
END MODULE M
 

PROGRAM P
USE :: M
IMPLICIT NONE (TYPE, EXTERNAL)
TYPE (T), TARGET :: X1
TYPE (T)         :: X2
X2%PTR => X1
WRITE(*, *) ASSOCIATED(X2%GET_PTR(), X1)
END PROGRAM P
0 Kudos
2 Replies
TobiasK
Moderator
312 Views

@OP1

thanks for reporting this. I escalated it to our developers. CMPLRLLVM-60612

In the meantime, a workaround is to use a temporary variable to hold the function result and passing that to ASSOCIATED


0 Kudos
TobiasK
Moderator
114 Views

@OP1


we implemented a fix which will be included in the next release, 2025.1.


0 Kudos
Reply