Nvfortran "Ambiguous interfaces for generic" inconsistency

Hi All,

I’m working on a piece of software that has a module for integer valued-code and a separate module for real-valued code. Both of these make use of interface blocks with the same name and rely on having a different type (bound to different names) to differentiate between them.

If I call the function from the same scope that this disambiguating variable is defined in, I get no issues, however if it’s in a nested subroutine I get the following:

NVFORTRAN-S-0155-Ambiguous interfaces for generic procedure foo (nvfortan-bug-broken.f90: 65)

I’ve uploaded a small code to demonstrate this (though I had to change the extension to upload them). There are 2 files, nvfortran-example-working.f90 and nvfortran-example-broken.f90 where the only difference is the nested subroutine. Both of these compile under gfortran.

nvfortan-example-working.txt (943 Bytes)
nvfortan-example-broken.txt (1.0 KB)

$ nvfortran --version

nvfortran 24.3-0 64-bit target on x86-64 Linux -tp sandybridge
NVIDIA Compilers and Tools
Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES.  All rights reserved.

$ gfortran --version
GNU Fortran (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO

$ nvfortran nvfortan-example-broken.f90
NVFORTRAN-S-0155-Ambiguous interfaces for generic procedure foo (nvfortan-example-broken.f90: 65)
NVFORTRAN-S-0155-Ambiguous interfaces for generic procedure foo (nvfortan-example-broken.f90: 66)
  0 inform,   0 warnings,   2 severes, 0 fatal for update

$ nvfortran nvfortan-example-working.f90

$ ./a.out
 d1%x =             1
 d2%x =     2.000000

Thanks for the report and nice reproducing examples.

I’ve filed a problem report, TPR #35642, and sent it to engineering for investigation.