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 II
637 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
511 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

0 Kudos
5 Replies
FortranFan
Honored Contributor II
625 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

 

0 Kudos
FortranFan
Honored Contributor II
625 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

 

0 Kudos
Barbara_P_Intel
Moderator
579 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.

 

0 Kudos
Barbara_P_Intel
Moderator
512 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.

0 Kudos
OP1
New Contributor II
468 Views
0 Kudos
Reply