Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

15.4.3.4.5 and C.11.6 are incomplete, needless, and largely unimplemented; delete them #327

Open
klausler opened this issue Jan 28, 2024 · 0 comments

Comments

@klausler
Copy link

Fortran has rules (15.4.3.4.5) that apply to each pair of specific procedures in a generic procedure interface. They are intended to ensure at the time of declaration (or merging via USE association) that every possible reference to that generic procedure can be unambiguously resolved to exactly one of its specific procedures.

These rules are incomplete, and the related note in C.11.6 admits as much. It is possible to write a generic interface that is unambiguous by inspection, yet still non-conformant to these rules.

Further, the goal of defining rules to prevent ambiguity in every possible reference is overkill. What is perhaps needed is only an assurance that it is possible to invoke each of the specific procedures unambiguously. Or, which nearly every compiler is doing anyway, it suffices to simply check each actual reference to a generic procedure to ensure that it resolves to exactly one of its specific procedures.

These rules appear not to have been implemented in gfortran, the Intel compilers, nvfortran, or in NAG. XLF has them, and as a result is unable to compile the unit test framework pFUnit. f18 had them, but I'm reducing them to portability warnings only, so that unambiguous existing applications can be compiled.

Example highly reduced from pFUnit:

module m
  interface generic
    procedure sub1, sub2
  end interface
 contains
  subroutine sub1(b, c)
    class(*) b
    integer, optional :: c
  end
  subroutine sub2(a, b, c)
    real a
    class(*) b
    integer, optional :: c
  end
end

The call generic(1.,2) would be ambiguous, but never happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant