- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на 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!

- Подписка на RSS-канал
- Отметить тему как новую
- Отметить тему как прочитанную
- Выполнить отслеживание данной Тема для текущего пользователя
- Закладка
- Подписаться
- Страница в формате печати