Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29285 Discussions

ICE and segfault with ifx and ifort for select rank and select type of class(*) argument

martinmath
New Contributor I
1,168 Views

ifx (2023.0.0 20221201) aborts with an ICE, classical ifort (2021.8.0 20221119) compiles but segfaults. (The code is boiled down from a pretty printer routine for debug purposes.)

 

program select_rank
implicit none

real :: x
integer :: y
x = 4.56
y = 5
call p(y)
call p((nint(x)))
call p(nint(x))
call p(fun(x))

contains

   function fun(x) result(y)
      integer :: y
      real, intent(in) :: x
      y = nint(x)
   end function fun

   subroutine p(v)
      class(*), dimension(..), intent(in) :: v
      select rank (v)
      rank (0)
         select type (v)
         type is (integer)
            print *, 'rank 0', v
         end select
      rank default
         print *, 'rank not supported'
      end select
   end subroutine p

end program select_rank
6 Replies
Ron_Green
Moderator
1,135 Views

Ouch, a bug for both ifx and ifort.  I'll write it up.

0 Kudos
martinmath
New Contributor I
1,118 Views

@Ron_Green wrote:

Ouch, a bug for both ifx and ifort.  I'll write it up.


Those compilers are not alone The code is from a gfortran bug report. Hence the different variants of how to call the subroutine p. Not all are handled by gfortran flawlessly.

Anyway, thanks for taking care.

0 Kudos
Ron_Green
Moderator
1,133 Views

Thank you for sending this to us. the bug ID is CMPLRLLVM-43747


0 Kudos
martinmath
New Contributor I
998 Views

Here is a variation, which also fails. I post it as the first testcase runs fine with current gnu fortran, but this new one fails with gfortran as well.

module mod

implicit none
private

type, public :: t
   integer :: i = 65
contains
   procedure :: get
end type t

contains

pure function get(self) result(i)
   integer :: i
   class(t), intent(in) :: self
   i = self%i
end function get

end module mod



program select_rank_tbproc
use mod
implicit none

type(t) :: x
class(t), pointer :: y

allocate(y, source=t(73))
call p(x%get()) ! fine
call p(y%get()) ! segfault
deallocate(y)

contains

subroutine p(v)
   class(*), dimension(..), intent(in) :: v
   select rank (v)
   rank (0)
      select type (v)
      type is (integer)
         print *, 'rank 0', v
      end select
   rank default
      print *, 'rank not supported'
   end select
end subroutine p

end program select_rank_tbproc
0 Kudos
Barbara_P_Intel
Employee
929 Views

Thank you! I added it to the bug report.

 

Ron_Green
Moderator
680 Views

I just confirmed the fix for this bug is in the 2024.1.0 compiler.


0 Kudos
Reply