Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

ICE on unlimited polymorphism

Satish_BD
Beginner
543 Views
Hi,

The following produces an Internal Compiler Error with ifort 12.0.3.174 on Ubuntu 10.10.
The trigger seems to be passing a null( ) as an actual argument to its corresponding dummy argument class(*).

Passing argument other than null() seems to work though.

======= begin test.F90 ==========

[fortran]module m_type
implicit none

type :: t_type
    real :: x
contains
    procedure :: eval_square
end type t_type

abstract interface    
    real function real_function(object, point)
        class(*) :: object
        real, intent(in) :: point
    end function real_function

end interface

contains

    real function eval_square(self, x)
      class(t_type) :: self
      real, intent(in) :: x
     
      eval_square = x**2

    end function eval_square

    real function find_roots(func, approx, object)
      procedure(real_function) :: func
      real, intent(in) :: approx
      class(*), optional :: object

      find_roots =  func(object, approx)

    end function find_roots

end module m_type

program main
use m_type
implicit none

type(t_type) :: t
real :: root root = find_roots(eval_square, 10.0, null()) ! Replace null() by 't' and the ICE is gone ! end program main [/fortran]


======= end test.F90 ==========

I couldn't reduce it to a simpler testcase, but I think this is small enough.


Thanks,
-- Satish.BD

0 Kudos
1 Solution
Steven_L_Intel1
Employee
543 Views
Thanks for reporting this problem. The use of NULL() as an actual argument where the dummy argument is OPTIONAL is a feature that is new in Fortran 2008 and which Intel Fortran does not yet support. If you remove the null() argument it works as you expect.

I'll report the issue of the ICE, which is always wrong, but I suggest that you remove the null() argument for now and just pass two arguments. Issue ID for the ICE is DPD200168881.

View solution in original post

0 Kudos
2 Replies
Steven_L_Intel1
Employee
544 Views
Thanks for reporting this problem. The use of NULL() as an actual argument where the dummy argument is OPTIONAL is a feature that is new in Fortran 2008 and which Intel Fortran does not yet support. If you remove the null() argument it works as you expect.

I'll report the issue of the ICE, which is always wrong, but I suggest that you remove the null() argument for now and just pass two arguments. Issue ID for the ICE is DPD200168881.
0 Kudos
Steven_L_Intel1
Employee
543 Views
Fixed in a future release.
0 Kudos
Reply