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

Compiler bug: Disallowing of valid function pointer reference in a pure procedure

much_ado
Beginner
234 Views

ifx (IFX) 2024.0.0 20231017 has what I believe to be a compiler bug that doesn't allow function pointer references, but not invocations, to non pure functions in a pure procedure. I believe this should be allowed based on 15.5.1 of the Fortran 2023 Standard:

 

R5120 function-reference is procedure-designator ( [ actual-arg-spec-list ] )

 

A procedure-designator is only a function-reference if it is followed by parentheses. As such, by my and my colleagues' reading of the standard, the procedure-designators (L22 in the following code sample) in a pure procedure should be allowed, but currently they cause a compile-time error.

 

Reproducer:

 

module test_m
  implicit none

  abstract interface
    logical function test_func_i()
      implicit none
    end function
  end interface

  type test_t
    procedure(test_func_i), pointer, nopass :: test_func_ => null()
  contains
    procedure :: eq
    generic :: operator(==) => eq
  end type 

contains

  pure function eq(lhs,rhs) result(lhs_eq_rhs)
    class(test_t), intent(in) :: lhs, rhs 
    logical lhs_eq_rhs
    lhs_eq_rhs = associated(lhs%test_func_,rhs%test_func_)
  end function 

end module

 

 

Compile error caused by above:

 

~/test$ ifx -c test_m.f90 
test_m.f90(22): error #7137: Any procedure referenced in a PURE procedure, including one referenced via a defined operation or assignment, must have an explicit interface and be declared PURE.   [TEST_FUNC_]
    lhs_eq_rhs = associated(lhs%test_func_,rhs%test_func_)
--------------------------------^
test_m.f90(22): error #7137: Any procedure referenced in a PURE procedure, including one referenced via a defined operation or assignment, must have an explicit interface and be declared PURE.   [TEST_FUNC_]
    lhs_eq_rhs = associated(lhs%test_func_,rhs%test_func_)
-----------------------------------------------^
test_m.f90(22): error #6106: Not a valid argument for ASSOCIATE or SELECT TYPE.   [ASSOCIATED]
    lhs_eq_rhs = associated(lhs%test_func_,rhs%test_func_)
----------------------------^
test_m.f90(22): internal error: Please visit 'http://www.intel.com/software/products/support' for assistance.
    lhs_eq_rhs = associated(lhs%test_func_,rhs%test_func_)
^
test_m.f90(22): catastrophic error: Internal Compiler Error: Ref module: ffe_axpnd.c
compilation aborted for test_m.f90 (code 1)

 

 

Thanks.

 

Labels (1)
1 Reply
Devorah_H_Intel
Moderator
128 Views

Thank you for bringing this to our attention. I have escalated the issue to our Compiler Engineering team for a fix. 

0 Kudos
Reply