- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
I have the following example code which does not compile with either IFX or IFORT. IFORT hangs with what looks like a memory leak, and IFX says the following
Compiling with Intel® Fortran Compiler 2024.2.1 [Intel(R) 64]...
test_type_type.f90
xfortcom: Fatal: There has been an internal compiler error (C00000FD).
ifx: error #10442: Could not remove 'x64\Debug\test_type_type.obj'
The code is
program test_type_type
implicit none
type :: test_type
integer :: i = 0
type( test_type ), allocatable :: next( : )
end type test_type
type(test_type), allocatable :: a( : )
type(test_type) :: b
allocate( a( 1 ) )
a = [ a, b ] ! This automatic reallocation fails
end program test_type_type
Is this automatic reallocation at line 10 'legal' Fortran given that type test_type has an allocatable component also of type test_type?
Thanks in advance
링크가 복사됨
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Interestingly, the following is fine in both compilers:
program test_type_type
implicit none
type :: test_type
integer :: i = 0
type( test_type ), allocatable :: next( : )
end type test_type
type(test_type), allocatable :: a( : )
type(test_type) :: b
allocate( a( 1 ) )
!a = [ a, b ] ! This auto-allocation fails for IFX
call extend( a, b )
contains
subroutine extend( a, b )
type( test_type ), allocatable, intent( inout ) :: a( : )
type( test_type ), intent( in ) :: b
type( test_type ), allocatable :: c( : )
call move_alloc( a, c )
allocate( a( size( c ) + 1 ) )
a( 1: size( c ) ) = c
a( size( c ) + 1 ) = b
deallocate( c )
return
end subroutine extend
end program test_type_type
so it looks like [ a, b ] is causing the problem
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Hi,
Would you please point me to any document explaining the syntax of automatic reallocation like:
a = [ a, b ]
I am not very familiar with the expected behavior here.
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
I believe I recall a thread discussing issues with this pattern of allocation some time in the last few months. I will do a search.
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Hi,
Yes, this is a very handy feature called automatic reallocation, it is a language standard equivalent of the procedure "extends" in my second post.
The array a must be allocatable
Following a = [ a, b ] a is extended by the contents of b
program demo
implicit none
integer, allocatable :: a(:)
a = [1,2,3,4]
a = [a,5]
print *,a
stop
end program demo
The point of my original post is that automatic reallocation should work for any intrinsic or user-defined type, but I demonstrate a user-defined type for which automatic reallocation does not compile.
Hope this helps
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
This issue is fixed in the 2025.1 ifx. The fix didn't make it to 2025.0 ifx, which is coming out by the end of this month.
