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

ICE returning abstract interface ifort 13.0.1 20121010

Joe_Z_
Beginner
253 Views

I have an internal compiler error when trying to return a function loaded from a dynamic library using an abstract interface and bindings to dlopen. This occurs on ifort 13.0.1 20121010 (and I believe older versions too). It compiles fine with ifort. This seems related to but not identical to previous problems reported on this forum. Error message and code below.

Thanks!

Joe Zuntz -bash-3.2$ ifort -c test.f90 test.f90: catastrophic error: **Internal compiler error: segmentation violation signal raised** 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

compilation aborted for test.f90 (code 1)

[fortran]
module dynamic_loading

use iso_c_binding
implicit none

interface

function dlopen(file,mode) result(handle) bind(c,name="dlopen")
use iso_c_binding
character(c_char), dimension(*), intent(in) :: file
integer(c_int), value :: mode
type(c_ptr) :: handle
end function

function dlsym(handle,name) result(funptr) bind(c,name="dlsym")
use iso_c_binding
type(c_ptr), value :: handle
character(c_char), dimension(*), intent(in) :: name
type(c_funptr) :: funptr
end function

end interface

abstract interface
function my_function_type(x) bind(c)
use iso_c_binding
integer(c_size_t), value :: x
integer(c_int) :: my_function_type
end function my_function_type
end interface

contains

function load_my_function(library_name, function_name) result(my_function)
character(kind=c_char,len=*) :: library_name, function_name
procedure(my_function_type), pointer :: my_function

type(c_funptr) :: funptr=c_null_funptr
type(c_ptr) :: handle=c_null_ptr
integer(c_int) :: status

handle=dlopen(trim(library_name)//c_null_char, 0)
funptr=dlsym(handle,trim(function_name)//c_null_char)

call c_f_procpointer(funptr, my_function)

end function load_my_function

end module
[/fortran]

0 Kudos
3 Replies
Steven_L_Intel1
Employee
253 Views

Thanks - I have escalated this to the developers as issue DPD200243371.  I am confused by your saying "it compiles fine with ifort" - was there more to that sentence?

0 Kudos
Joe_Z_
Beginner
253 Views

Many thanks, and apologies - I meant that it compiiles fine under gfortran (4.5 and above). 

0 Kudos
Steven_L_Intel1
Employee
253 Views

In the current version (16), an ICE no longer occurs but an incorrect warning is produced instead:

t.f90(28): warning #6178: The return value of this FUNCTION has not been defined.   [MY_FUNCTION]
procedure(my_function_type), pointer :: my_function
----------------------------------------^

This will be fixed in the next major version (second half of 2016).

0 Kudos
Reply