J3/05-265 Date: 3 Oct 2005 To: J3 From: Richard Maine Subject: Subroutine/function ambiguity in generics NUMBER: TITLE: Subroutine/function ambiguity in generics KEYWORDS: subroutine, generic, implicit DEFECT TYPE: STATUS: Submitted QUESTION: Q1. Is the following generic allowed? interface q subroutine qr(f) implicit real(f) external f end subroutine subroutine qc(f) implicit complex(f) external f end subroutine end interface q The uncertainly arises because it is not established whether F is a subroutine or a function. If either F were a subroutine, then it would be clear that the generic was disallowed. One might be able to use this to deduce that both Fs must be functions. This seems like an obscure deduction to demand of the compiler. Q2. Consider the following "obviously" allowed generic module m interface q subroutine qr(f) real, external :: f end subroutine subroutine qc(f) complex, external :: f end subroutine end interface q end module m Is the following main program valid? program main use m external ff call q(ff) end Again, the problem is that it is unclear whether of not ff is a function or subroutine. If it is a subroutine, then the call is ambiguous. One might thus deduce that ff must be a function, and therefore of type real, but this seems like an obscure deduction to demand of the compiler. ANSWER: I'm not sure. But presumably either the compiler is required to make the mentioned deductions or the code must be nonconforming. If the code is intended to be nonconforming, edits to say so might be needed. EDITS To be supplied. SUBMITTED BY: Richard Maine HISTORY: J3/05-265 m174 Submitted