Hi,
I am facing an issue with ifort 17.0 (the same code was working fine with ifort 12.1 and 16.0) on a simple code where I try to deallocate the fptr returned by C_F_POINTER from ISO_C_BINDING (I associate there the pointer to a C allocated array of char). The error on program compiled with ifort 17.0 is:
forrtl: severe (173): A pointer passed to DEALLOCATE points to an object that cannot be deallocated
Here is the snippet of code:
program testalloc use ISO_C_BINDING implicit none interface function c_alloc(buf) bind(C,name="alloc_in_c") use ISO_C_BINDING integer(C_INT) :: c_alloc type(C_PTR), intent(out) :: buf end function c_alloc end interface type(C_PTR) :: cptr character, dimension(:), pointer :: fptr character(128) :: s integer :: len, i len = c_alloc(cptr) call C_F_POINTER(cptr, fptr, (/len/)) s = '' do i=1,len s(i:i) = fptr(i) end do print *,"obtained string = ",TRIM(s) if (associated(fptr)) then deallocate(fptr) end if end program testalloc
As no error was detected with previous version of the compiler, I was wondering if it could be a bug in this 17.0 version or if my code was simply not valid but that was not detected/enforced previously?
Thanks
Olivier