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

ICE using iso_c_binding

Arjen_Markus
Honored Contributor II
409 Views
Hello,

I am using Intel Fortran 11.1.065 on Windows and the following program causes an access violation
when I compile it (using default options):

! chk.f90 --

! Simple program to check why iso_c_binding causes

! an ICE
!
module chk
use user32
use kernel32
use iso_c_binding

type hq_type

double precision :: h
double precision :: q
end type

contains

subroutine read_hq( location, hq_data )
character(len=*) :: location
type(hq_type), dimension(*) :: hq_data

integer :: p, q

pointer (q, ReadHQ)

type(c_ptr) :: hq_data_c

integer, dimension(1) :: hq_data_length

p = loadlibrary ("library.dll"C) ! the C at the end says add a null byte as in C
q = getprocaddress (p, "_ReadHQ"C)

call ReadHQ ( location, hq_data_c, hq_data_length )
call c_f_pointer( hq_data_c, hq_data, hq_data_length )

end subroutine read_hq

end module


While I prefer to link against the DLL instead of loading it this way (we had some trouble doing it via linking), the compiler should not abort.

Regards,

Arjen

0 Kudos
4 Replies
Arjen_Markus
Honored Contributor II
409 Views
I have solved the immediate problem: hq_data should have been a pointer variable.

Having solved that and a few other issues in the actual code (I reduced it to this example) I now
have a working program.

(A confusing messageduring that process was the linkercould not find _c_f_pointer - this was solved
when Iintroducedan interface block to a C++ function I am using, or at least so it seems)

Regards,

Arjen
0 Kudos
Steven_L_Intel1
Employee
409 Views
Thanks - I can reproduce the ICE and will report it to the developers. Issue ID is DPD200161693.

Can you tell me more about the linker error? Are you using any switches such as /names:as_is? Can you show me a test case that gives that error?
0 Kudos
Arjen_Markus
Honored Contributor II
409 Views
I will try - I was rather anxious to get this issue solved, so I made a lot of changes on the way.

Regards,

Arjen
0 Kudos
Arjen_Markus
Honored Contributor II
409 Views
Unfortunately, I have been unable to reproduce it. Should it occur again, I will certainly report it.

Regards,

Arjen
0 Kudos
Reply