Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

ICE with assumed-rank array

OP1
新分销商 III
985 次查看

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

 

 

 

0 项奖励
1 解答
Barbara_P_Intel
859 次查看

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.

在原帖中查看解决方案

0 项奖励
5 回复数
FortranFan
名誉分销商 III
973 次查看

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

 

0 项奖励
FortranFan
名誉分销商 III
973 次查看

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

 

0 项奖励
Barbara_P_Intel
927 次查看

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.

 

0 项奖励
Barbara_P_Intel
860 次查看

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.

0 项奖励
OP1
新分销商 III
816 次查看
0 项奖励
回复