Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
25 Views

ICE in 19.04 with type bound generic interface

Hi,

the following code generates an internal compiler error when compiled with 19.04

Module Mod_Paof
  Implicit none
  Private
  Type, Public :: parent
  contains
    Private
    Generic, Public :: bar => foo
    Procedure, Public :: foo => subfoo_parent
  End type parent
  Type, Public, extends(parent) :: offspring
  contains
    Private
    Procedure, Public :: foo => subfoo_offspring
  End type offspring
  Interface
    Module Subroutine subfoo_parent(this)
      Class(parent), Intent(inOut) :: this
    End Subroutine
    Module Subroutine subfoo_offspring(this)
      Class(offspring), Intent(inOut) :: this
    End Subroutine
  End Interface
End Module Mod_Paof
Submodule(Mod_Paof) parent_foo
contains
  Module Procedure subfoo_parent
    Implicit None
  End Procedure
End Submodule parent_foo
Submodule(Mod_Paof) offspring_foo
contains
  Module Procedure subfoo_offspring
    Implicit None
  End procedure
End Submodule offspring_foo
Module Mod_Ttt
  use Mod_Paof, only: offspring
  Implicit None
  Private
  Type, Public :: Ttt
    Type(offspring), allocatable :: xxx
  contains
    Private
    Procedure, Pass, Public :: bar=> Subbar
  End type Ttt
  Interface
    Module Subroutine Subbar(this)
      Class(Ttt), Intent(InOut) :: this
    End Subroutine
  End Interface
End Module Mod_Ttt
Submodule(Mod_Ttt) ttt_bar
contains
  Module Procedure Subbar
    Implicit None
    !!ice crash
    call this%xxx%bar()
    !!workaround (not really)
    !call this%xxx%foo()
  End Procedure
end Submodule Ttt_Bar

it compiles with gfortran 8.3 and ifort 17.08.

The workaround is to abandon the generic interface.

cheers

0 Kudos
3 Replies
Highlighted
Valued Contributor I
25 Views

Confirmed. Please submit a bug report. The ICE is still in the beta version ifort 2020.

0 Kudos
Highlighted
Valued Contributor III
25 Views

may.ka wrote:

..

it compiles with gfortran 8.3 and ifort 17.08.

The workaround is to abandon the generic interface.

With the code in the original post, Intel Fortran compiler versions 18.0 Official Release, 18.0 Update 3, 18.0 Update 5, as well as 19.0 Official Release avoid the ICE and compile the code without errors.  Whereas 19.0 Updates 1, 2, 3, and 4 encounter the ICE. 

Another workaround is to implement the 'parent' and 'offspring' derived types in separate modules which might then help code readability and perhaps make matters easier for the compiler that then avoids the ICE while retaining the generic interface.

Module Mod_P
  Implicit none
  Private
  Type, Public :: parent
  contains
    Private
    Generic, Public :: bar => foo
    Procedure, Public :: foo => subfoo_parent
  End type parent
  Interface
    Module Subroutine subfoo_parent(this)
      Class(parent), Intent(inOut) :: this
    End Subroutine
  End Interface
End Module Mod_P
Submodule(Mod_P) parent_foo
contains
  Module Procedure subfoo_parent
    Implicit None
  End Procedure
End Submodule parent_foo
Module Mod_F
   use Mod_P, only : parent
  Implicit none
  Private
  Type, Public, extends(parent) :: offspring
  contains
    Private
    Procedure, Public :: foo => subfoo_offspring
  End type offspring
  Interface
    Module Subroutine subfoo_offspring(this)
      Class(offspring), Intent(inOut) :: this
    End Subroutine
  End Interface
End Module Mod_F
Submodule(Mod_F) offspring_foo
contains
  Module Procedure subfoo_offspring
    Implicit None
  End procedure
End Submodule offspring_foo
Module Mod_Ttt
  use Mod_F, only: offspring
  Implicit None
  Private
  Type, Public :: Ttt
    Type(offspring), allocatable :: xxx
  contains
    Private
    Procedure, Pass, Public :: bar=> Subbar
  End type Ttt
  Interface
    Module Subroutine Subbar(this)
      Class(Ttt), Intent(InOut) :: this
    End Subroutine
  End Interface
End Module Mod_Ttt
Submodule(Mod_Ttt) ttt_bar
contains
  Module Procedure Subbar
    Implicit None
    !!ice crash at instruction below with parent and offspring in same module
    call this%xxx%bar()
  End Procedure
end Submodule Ttt_Bar
C:\Temp>type ugly.f90
Module Mod_P
  Implicit none
  Private
  Type, Public :: parent
  contains
    Private
    Generic, Public :: bar => foo
    Procedure, Public :: foo => subfoo_parent
  End type parent
  Interface
    Module Subroutine subfoo_parent(this)
      Class(parent), Intent(inOut) :: this
    End Subroutine
  End Interface
End Module Mod_P
Submodule(Mod_P) parent_foo
contains
  Module Procedure subfoo_parent
    Implicit None
  End Procedure
End Submodule parent_foo
Module Mod_F
   use Mod_P, only : parent
  Implicit none
  Private
  Type, Public, extends(parent) :: offspring
  contains
    Private
    Procedure, Public :: foo => subfoo_offspring
  End type offspring
  Interface
    Module Subroutine subfoo_offspring(this)
      Class(offspring), Intent(inOut) :: this
    End Subroutine
  End Interface
End Module Mod_F
Submodule(Mod_F) offspring_foo
contains
  Module Procedure subfoo_offspring
    Implicit None
  End procedure
End Submodule offspring_foo
Module Mod_Ttt
  use Mod_F, only: offspring
  Implicit None
  Private
  Type, Public :: Ttt
    Type(offspring), allocatable :: xxx
  contains
    Private
    Procedure, Pass, Public :: bar=> Subbar
  End type Ttt
  Interface
    Module Subroutine Subbar(this)
      Class(Ttt), Intent(InOut) :: this
    End Subroutine
  End Interface
End Module Mod_Ttt
Submodule(Mod_Ttt) ttt_bar
contains
  Module Procedure Subbar
    Implicit None
    !!ice crash at instruction below with parent and offspring in same module
    call this%xxx%bar()
  End Procedure
end Submodule Ttt_Bar

C:\Temp>ifort /c /standard-semantics /warn:all /stand:f18 ugly.f90
Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64,
Version 19.0.4.245 Build 20190417
Copyright (C) 1985-2019 Intel Corporation.  All rights reserved.

ugly.f90: remark #7712: This variable has not been used.   [THIS]

C:\Temp>

Hopefully Intel support team has received incident request(s) on this to implement a bug resolution toward the ICE.

0 Kudos
Highlighted
Beginner
25 Views

The ice above persists with release 19.1 (parallel studio 20.0). Intel has indicated that the bug will be fixed in "some future version".

A workaround which keeps the module-submodule structure in place is:

Module Mod_Paof
  Implicit none
  Private
  Type, Public :: parent
  contains
    Private
    !!the generic interface is the trouble maker
    Generic, Public :: bar => foo
    Procedure, Public :: foo => subfoo_parent
  End type parent
  Type, Public, extends(parent) :: offspring
  contains
    Private
    Procedure, Public :: foo => subfoo_offspring
  End type offspring
  Interface
    Module Subroutine subfoo_parent(this)
      Class(parent), Intent(inOut) :: this
    End Subroutine
    Module Subroutine subfoo_offspring(this)
      Class(offspring), Intent(inOut) :: this
    End Subroutine
  End Interface
End Module Mod_Paof
Submodule(Mod_Paof) parent_foo
contains
  Module Procedure subfoo_parent
    Implicit None
  End Procedure
End Submodule parent_foo
Submodule(Mod_Paof) offspring_foo
contains
  Module Procedure subfoo_offspring
    Implicit None
  End procedure
End Submodule offspring_foo
Module Mod_Ttt
  use Mod_Paof, only: offspring
  Implicit None
  Private
  Type, Public :: Ttt
    !!workaround: declare "class" instead of "type" for
    !!being able to do a type resolution in subbar
    class(offspring), allocatable :: xxx
  contains
    Private
    Procedure, Pass, Public :: bar=> Subbar
  End type Ttt
  Interface
    Module Subroutine Subbar(this)
      Class(Ttt), Intent(InOut) :: this
    End Subroutine
  End Interface
End Module Mod_Ttt
Submodule(Mod_Ttt) ttt_bar
contains
  Module Procedure Subbar
    !!this use statement is redundant but when missing will cause an ICE
    use mod_paof, only: offspring
    Implicit None
    !!workaround: do a type resolution
    select type(z=>this%xxx)
    class is(offspring)
      call z%bar()
    end select
  End Procedure
end Submodule Ttt_Bar
program test
end program test

 

0 Kudos