This is an ICE with ifort classic 2021.2.0.
SUBROUTINE S(A, B)
IMPLICIT NONE
INTEGER, ALLOCATABLE :: A(..)
INTEGER :: B
SELECT RANK (A)
RANK (0)
B = -HUGE(A)
RANK DEFAULT
B = -HUGE(A(1))
END SELECT
END SUBROUTINE S
Edit: even simpler reproducer:
SUBROUTINE S(A, B)
INTEGER :: A(..),B
SELECT RANK (A)
RANK DEFAULT
B = A(1)
END SELECT
END SUBROUTINE S
The 2021.3.0 Fortran compiler was released last week. I compiled with that version and no ICE!
@OP1 Please give it a try and let me know how it works for you.
链接已复制
IFORT in oneAPI 2021.2 lets the following non-conforming code pass, that might be playing a role leading up to the dreadful ICE:
subroutine s(A, B)
integer :: A(..), B
B = A(1) !<-- does not conform to the standard
end
Thankfully the conforming variant of the code that uses RANK(*) instead of RANK DEFAULT (which leaves the associating entity as assumed-rank and thus has limitations as to the contexts it can appear)
module m
contains
subroutine sub( x, y )
integer :: x(*)
integer :: y
call s(x,y)
end subroutine
subroutine s(a, b)
integer :: a(..), b
select rank ( a )
rank (0)
b = a
rank (*)
b = a(1)
end select
end subroutine
end module
use m
integer :: p(1), q, r
p = 42
call sub( p, q )
print *, "q = ", q, "; expected is 42"
call s( q, r )
print *, "r = ", r, "; expected is 42"
end
produces the expected output:
C:\temp>ifort /standard-semantics s.f90
Intel(R) Fortran Intel(R) 64 Compiler Classic for applications running on Intel(R) 64, Version 2021.2.0 Build 20210228_000000
Copyright (C) 1985-2021 Intel Corporation. All rights reserved.
Microsoft (R) Incremental Linker Version 14.27.29112.0
Copyright (C) Microsoft Corporation. All rights reserved.
-out:s.exe
-subsystem:console
s.obj
C:\temp>s.exe
q = 42 ; expected is 42
r = 42 ; expected is 42
That's good news for the workaround!
The other good news is that the ICE is gone in an internal version of the next compiler release. Looks like this version should be available to you within the next couple of months.
The 2021.3.0 Fortran compiler was released last week. I compiled with that version and no ICE!
@OP1 Please give it a try and let me know how it works for you.
