Compiler bug: linker can't find subroutine from own module

Hi,

The following MWE

module m_constants

  integer :: the_answer = 42
end module

module m_fancy_module
  implicit none

  private
  public :: caller
contains
  subroutine caller
    use m_constants ! Without this use statement everything is fine

    call hi
  end subroutine

  subroutine hi
    use m_constants

    print*, "The answer is ", the_answer

  end subroutine hi
end module


program example
  use m_fancy_module
  implicit none

  call caller
  
end program example

results in unexpected behavior (starting at NVFortran 25.3)

❯ gfortran mwe.F90 && ./a.out
 The answer is           42
❯ nvfortran mwe.F90 && ./a.out
/usr/bin/ld: /tmp/nvfortranIYEkbMAhzbYNh.o: in function `m_fancy_module_caller_':
/home/ronald/Documents/gkpic_fork/euterpe/mwe.F90:15:(.text+0x84): undefined reference to `hi_'

Hi Ronald,

Thanks for the report! Looks like a regression starting in our 25.3 release. I’m guessing engineering fixed something but accidently broke this.

I filed a problem report, TPR #38394, and sent it to the Fortran front-end team.

Work around is to remove “private”.

-Mat

FYI, TPR #38394 was fixed in our 26.5 release.

-Mat

% nvfortran test.F90 -V26.3
/usr/bin/ld: /tmp/nvfortranDb2nnxYFvNFvL.o: in function `m_fancy_module_caller_':
/local/home/mcolgrove/test.F90:15: undefined reference to `hi_'
% nvfortran test.F90 -V26.5
%