Catastrophic Compiler Error related to abstract interface and procedure pointers

Catastrophic Compiler Error related to abstract interface and procedure pointers

Hi everybody,

When accessing a function through a pointer defined by an abstract interface, I get internal compiler catastrophic error. The example code is the following:

module modl
  implicit none
  integer    :: m
end module modl

module type_def
  implicit none
  type mytype
    real   :: a,b
    integer  :: n
  end type mytype
end module type_def

module function_def
  implicit none
  abstract interface
    function func(a)
      use modl,         only : m
      use type_def,       only : mytype
      implicit none
      class(mytype),intent(in)    :: a
      complex                     :: func(m*a%n)
    end function func
  end interface
  procedure(func),pointer   :: p => null()

 contains

  subroutine evaluate_fun(a)
    use modl,      only : m
    use type_def,  only : mytype
    implicit none
    type(mytype),intent(in)  :: a
    complex                  :: res(m*a%n)

    res = p(a)
    print *,' evaluate_fun: res = ',res

  end subroutine evaluate_fun

  subroutine set_pointer()
    implicit none
    p => myfunc
  end subroutine set_pointer

  function myfunc(a)
    use type_def,  only : mytype
    use modl,      only : m
    implicit none
    class(mytype),intent(in)  :: a
    complex                   :: myfunc(m*a%n)

    myfunc = 1.0
  end function myfunc

end module function_def

program test_catastrophic
  use modl,         only : m
  use type_def,     only : mytype
  use function_def, only : set_pointer,p,evaluate_fun
  implicit none
  type(mytype)   :: a
  complex        :: res(15)

  a%n = 5
  m = 3

  call set_pointer()
  call evaluate_fun(a)
  res = p(a)
  print *,'main program: res = ',res

end program test_catastrophic

 

The program reports the following error while compiling:

0_12459

: catastrophic error: **Internal compiler error: internal abort** Please report this error along with the circumstances in which it occurred in a Software Problem Report.  Note: File and line given may not be explicit cause of this error.

If function evaluate_fun is not present in the module function_def (and of course not called in the main program), the program compiles and runs as expected. Why does it break down when the function is accessed (through pointer p) in the module procedure, but not when accessed from the main program?

The program also runs if the function interface is changed to include m as a dummy variable, but that solution isn't easy to implement in the actual code.

The Fortran version is:

> ifort -v
ifort version 12.1.0

 

I would appreciate any ideas, suggestions or explanations.

Thanks,

Grgur

7 posts / 0 nouveau(x)
Dernière contribution
Reportez-vous à notre Notice d'optimisation pour plus d'informations sur les choix et l'optimisation des performances dans les produits logiciels Intel.

I can't help you with that directly but I can tell you that your code compiles and runs on the latest compiler:

U:\>ifort t.f90
Intel(R) Visual Fortran Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 14.0.3.202 Build 20140422
Copyright (C) 1985-2014 Intel Corporation.  All rights reserved.

Microsoft (R) Incremental Linker Version 10.00.30319.01
Copyright (C) Microsoft Corporation.  All rights reserved.

-out:t.exe
-subsystem:console
t.obj

U:\>t.exe
  evaluate_fun: res =  (1.000000,0.0000000E+00) (1.000000,0.0000000E+00)
 (1.000000,0.0000000E+00) (1.000000,0.0000000E+00) (1.000000,0.0000000E+00)
 (1.000000,0.0000000E+00) (1.000000,0.0000000E+00) (1.000000,0.0000000E+00)
 (1.000000,0.0000000E+00) (1.000000,0.0000000E+00) (1.000000,0.0000000E+00)
 (1.000000,0.0000000E+00) (1.000000,0.0000000E+00) (1.000000,0.0000000E+00)
 (1.000000,0.0000000E+00)
 main program: res =  (1.000000,0.0000000E+00) (1.000000,0.0000000E+00)
 (1.000000,0.0000000E+00) (1.000000,0.0000000E+00) (1.000000,0.0000000E+00)
 (1.000000,0.0000000E+00) (1.000000,0.0000000E+00) (1.000000,0.0000000E+00)
 (1.000000,0.0000000E+00) (1.000000,0.0000000E+00) (1.000000,0.0000000E+00)
 (1.000000,0.0000000E+00) (1.000000,0.0000000E+00) (1.000000,0.0000000E+00)
 (1.000000,0.0000000E+00)

 

Hi sgeard,

 

Thanks for your tip! I will see if we can get the new version of ifort installed. So no ideas what might be wrong when calling the pointer-assigned function from the same module (i.e. using evaluate_fun subroutine)?

 

Grgur

You encountered a compiler bug that was fixed. It's not worthwhile to ask "what might be wrong" at this point.

Steve

Hi Steve,

 

Thanks for letting me know. I was asking because I was not sure whether it's my bad coding or is it really ifort's bug. 

 

Best,

Grgur

An internal compiler error is ALWAYS a compiler bug, even if it is prompted by a source error. Since sgeard reports that the program builds and runs with a current version, it's pretty likely not a source error.

Steve

Thanks a lot for your help!

Connectez-vous pour laisser un commentaire.