Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
1 View

Possible undetected interface inconsistency?

The code below, as is, will compile and create the following error at runtime: "forrtl: severe (173): A pointer passed to DEALLOCATE points to an object that cannot be deallocated"

Now, if you toggle lines 39 and 40, the code runs as expected.

However, ror the case that fails, shouldn't the compiler detect the (incorrect?) use of TYPE instead of CLASS on line 39 though?

MODULE M1
IMPLICIT NONE
TYPE,ABSTRACT :: T
    CHARACTER(LEN=:),ALLOCATABLE :: S
    CONTAINS
        PROCEDURE(P),DEFERRED,PASS(ARG) :: P
END TYPE T
PRIVATE :: P
ABSTRACT INTERFACE
    SUBROUTINE P(ARG)
    IMPORT :: T
    IMPLICIT NONE
    CLASS(T) :: ARG
    END SUBROUTINE P
END INTERFACE
END MODULE M1

MODULE M2
USE M1
IMPLICIT NONE
TYPE,EXTENDS(T) :: TT
    CONTAINS
        PROCEDURE,PASS(ARG) :: P
END TYPE TT
PRIVATE :: P
INTERFACE
    MODULE SUBROUTINE P(ARG)
    IMPLICIT NONE
    CLASS(TT) :: ARG
    END SUBROUTINE P
END INTERFACE
END MODULE M2

SUBMODULE (M2) SM
IMPLICIT NONE
CONTAINS
    MODULE SUBROUTINE P(ARG)
    IMPLICIT NONE
    TYPE(TT) :: ARG    ! This will trigger an error at run time.
    !CLASS(TT) :: ARG   ! This works.
    ARG%S = 'oOOoops!'
    END SUBROUTINE P
END SUBMODULE SM

PROGRAM MAIN
USE M2
IMPLICIT NONE
TYPE(TT) :: W
CALL W%P
WRITE(*,*) W%S
END PROGRAM MAIN

 

0 Kudos
1 Reply
Highlighted
1 View

Thanks for reporting the

Thanks for reporting the issue. I have reproduced the error and open a bug report for it. The track ID is DPD200414511.

 

Thanks,

Xiaoping Duan

Intel Customer Support

0 Kudos