NVFORTRAN: Internal compiler error

I got this error:

$ nvfortran -c dmpinf.f90 -o dmpinf.f90.o   
NVFORTRAN-F-0000-Internal compiler error. Error in c_f_pointer() - unable to find c_ptr type     144  (dmpinf.f90: 28)
NVFORTRAN/x86-64 Linux 21.3-0: compilation aborted

on the following file:

module definitions
  use, intrinsic :: iso_fortran_env, only: int64, real64
  use, intrinsic :: iso_c_binding, only: c_double

  implicit none
  private
  public :: wp, iwp, cdp

  integer(kind=int64), parameter :: iwp = int64
  integer(kind=iwp), parameter :: wp = real64, cdp = c_double

end module definitions

subroutine DmpInf()
  use definitions
  implicit none
  integer :: lRFStrt

  call DmpInf_Internal(lRFStrt)

  contains

  subroutine DmpInf_Internal(lRFStrt)
    use, intrinsic :: iso_c_binding, only: c_f_pointer, c_loc
    integer, target :: lRFStrt
    integer, pointer :: p_lRF

    call c_f_pointer(c_loc(lRFStrt),p_lRF)
    nullify(p_lRF)

  end subroutine DmpInf_Internal
end subroutine DmpInf

The problem disappears if definitions is not used (but note no variable from it is referenced), or if iso_c_binding is not used inside definitions (but note those are private). It also disappears if the internal subroutine is moved into the main one, but this of course is just a reduction of a much more complex program where that is not possible.

I tested with version:

$ nvfortran --version

nvfortran 21.3-0 LLVM 64-bit target on x86-64 Linux -tp skylake 
NVIDIA Compilers and Tools
Copyright (c) 2020, NVIDIA CORPORATION.  All rights reserved.

Other compilers seem to have to problem with this. I haven’t been able to find a workaround.

Correction: it seems to work if I move the use iso_c_binding to the host subroutine.

Thanks for the report! I was able to reproduce the error here and have filed problem report TPR #30160. We’ll have one of our engineers investigate.

-Mat

FYI, TPR #30160 was fixed in the 22.11 release.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.