You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Flang] Incorrect execution result when the arguments described in SAME_TYPE_AS intrinsic function are defined in derived types with the same name but different definitions in different modules of different subroutines #135580
Version of flang : 21.0.0(9fe6f6a0d430b872750354c20f3e4a651bd1f135)/AArch64
The arguments (dmyptr and baseobj) described in SAME_TYPE_AS intrinsic function are defined in derived types with the same name (deriv) but different definitions in different modules (module3 and module4) of different subroutines (sub1 and sub2).
Thus, the result of the SAME_TYPE_AS intrinsic function should be F because they are different types, even if they are defined by a derived type of the same name.
The following are the test program, Flang, Gfortran and ifx compilation/execution result.
Polymorphism_FT_sametypeas_046_22.f90:
MODULE MODULE3
IMPLICIT NONELOGICAL::x
TYPE base
integer::int1
END TYPE base
TYPE ,EXTENDS(base)::deriv
INTEGER:: int2
END TYPE deriv
END MODULE MODULE3
MODULE MODULE4
IMPLICIT NONE
TYPE base
INTEGER::ii
END TYPE base
TYPE ,EXTENDS(base):: deriv
INTEGER:: kk
END TYPE deriv
END MODULE MODULE4
PROGRAM MAIN
IMPLICIT NONE
INTERFACE
SUBROUTINEsub2ENDSUBROUTINEsub2
END INTERFACE
call sub2()
END PROGRAM MAIN
SUBROUTINEsub1(dmyptr)
use MODULE3
CLASS(*)::dmyptr
TYPE(deriv)::baseobj
LOGICAL::res
res=SAME_TYPE_AS(dmyptr,baseobj)
write(6,*) "res = ", res
ENDSUBROUTINE sub1SUBROUTINEsub2()
use MODULE4
INTERFACE
SUBROUTINEsub1(dmy1)
CLASS(*)::dmy1
ENDSUBROUTINEsub1
end interface
CLASS(base),POINTER::ptr_base
TYPE(deriv),TARGET::tar_ty1
ptr_base=>tar_ty1
call sub1(ptr_base)
ENDSUBROUTINE sub2
$ flang Polymorphism_FT_sametypeas_046_22.f90; ./a.out
res = T
$
$ gfortran Polymorphism_FT_sametypeas_046_22.f90; ./a.out
res = F
$
$ ifx Polymorphism_FT_sametypeas_046_22.f90; ./a.out
res = F
$