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
New Contributor I
408 Views

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 Kudos
1 Solution
Barbara_P_Intel
Moderator
282 Views

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.

View solution in original post

5 Replies
FortranFan
Honored Contributor II
396 Views

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

 

FortranFan
Honored Contributor II
396 Views

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

 

Barbara_P_Intel
Moderator
350 Views

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.

 

Barbara_P_Intel
Moderator
283 Views

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.

OP1
New Contributor I
239 Views
Reply