- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Dear Intel Fortran maintainers,
The following minimal working example demonstrates a possible bug in the current Intel Fortran compilers (ifort (IFORT) 2021.8.0 20221119 and ifx (IFORT) 2023.0.0 20221201).
When a structure constructor is renamed, its return type seems not be recognized correctly afterwards. Note, that using the original (non-renamed) name, the assignment (line 40) works fine, while the assignment with the renamed entities (line 48) triggers following compiler error:
> ifort -c intelbug.f90
intelbug.f90(48): error #7497: The variable must be type compatible with the expression and of the same rank. [INSTANCE]
renamedcls%instance = renamed_type()
---------------^
compilation aborted for /home/aradi/sync/bccms/devel/fortuno/intelbug.f90 (code 1)
module testmod
implicit none
type :: orig_type
end type orig_type
interface orig_type
module procedure new_orig_type
end interface orig_type
type :: orig_type_cls
class(orig_type), allocatable :: instance
end type orig_type_cls
contains
function new_orig_type() result(this)
type(orig_type) :: this
end function new_orig_type
end module testmod
module testmod2
use testmod, only : orig_type, orig_type_cls
use testmod, only : renamed_type => orig_type, renamed_type_cls => orig_type_cls
end module testmod2
module testmod3
implicit none
contains
subroutine test1()
use testmod2, only : orig_type, orig_type_cls
type(orig_type_cls) :: origcls
! Works without problems
origcls%instance = orig_type()
end subroutine test1
subroutine test2()
use testmod2, only : renamed_type, renamed_type_cls
type(renamed_type_cls) :: renamedcls
! Renamed type does not work as expected
renamedcls%instance = renamed_type()
end subroutine test2
end module testmod3
링크가 복사됨
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Intel compiler is wrong to issue the #7497 error here, clearly a bug that Intel Fortran team would want to fix also because it appears to be in the handling of the intermediate module with renamed entities, something that can have other, bigger implications.
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Thanks for reporting this. I filed a bug, CMPLRLLVM-45336. I'll let you know when it's fixed.
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
@Barbara_P_Intel Do you know if this bug will be fixed in the 2024.1 release? It affects a code that I work with quite a bit, which heavily depends on polymorphism and constructors. Also, I don't know if it's relevant, but I've found that the issue does not occur when "class" is replaced with "type" in line 12 in OP's example.
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
The fix is not in the preview 2024.1.0 bits I have available. Code freeze is imminent. Doesn't look promising.
I'll pass along the change you identified to the compiler team.
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
I'm not getting the error message with the nightly 2024.2.0 compilers. Look for this version's release in mid-2024.
Watch for the announcement!
