[Patch, Fortran] C Binding - module+intrinsic cleanup+bug fixes
Tobias Burnus
burnus@net-b.de
Mon Mar 25 16:43:00 GMT 2013
Dominique Dhumieres wrote:
> Is it expected that the test gfortran.dg/c_loc_test_19.f90 segfaults
> at runtime?
Yes, it is expected. "type(c_ptr), POINTER :: b" is never allocated /
associated.
Try allocate(b) or the following test case.
Dominque, Mikael, all: Does it make sense to add such a test case? I
haven't checked whether a similar one already exists. (It works with 4.5
to 4.8 and with the current trunk.)
Tobias
use iso_c_binding
type(c_ptr), pointer :: ptr, ptr2
integer, target :: tgt
integer, pointer :: iptr
allocate (ptr)
tgt = 55
ptr = c_loc(tgt)
if (.not. c_associated (ptr, c_loc(tgt))) stop 'error 1' !call abort ()
ptr2 => ptr
call c_f_pointer (ptr2, iptr)
deallocate (ptr2)
if (iptr /= 55 .or. .not. associated (iptr, tgt))stop 'error 2' ! call
abort ()
end
More information about the Fortran
mailing list