J3/05-127r1 Date: 8 February 2005 To: J3 From: Van Snyder Subject: Implicit interfaces and conflicting references NUMBER: TITLE: Implicit interfaces and conflicting references KEYWORDS: implicit interface, procedure pointer, dummy procedure, procedure reference DEFECT TYPE: STATUS: J3 consideration in progress QUESTION: Is the following program legal: _________________________ module test_mod contains subroutine reference(proc,choice) ! Proc has implicit interface external :: proc ! Or ! procedure(), pointer :: proc logical :: choice if(choice) then call proc(1.0) ! Call with real argument else call proc(1) ! Call with integer argument end if end subroutine subroutine proc_real(x) real :: x end subroutine subroutine proc_integer(x) integer :: x end subroutine end module program test use test_mod call reference(proc_real,.true.) call reference(proc_integer,.false.) end program _________________________ 12.3.2.5 says: "The type...of dummy arguments of a procedure referenced from a scoping unit where the interface of the procedure is implicit shall be such that the actual arguments are consistent with the characteristics of the dummy arguments." We define a procedure reference in 2.5.6 as the "appearance of procedure designator, ... in a context requiring execution at that point." Are both calls to proc above references, at compile time? If both calls to proc are references then they both need to be consistent with the interface of the actual argument associated with the dummy procedure. This is not possible and the program would be illegal. However, if only the call executed counts as a reference, than the program is legal. The same question applies to both dummy procedures and procedure pointers with implicit interfaces. ANSWER: The program is not standard conforming. Both calls to PROC in the module subroutine REFERENCE are references to the dummy procedure PROC and must be consistent. Consider the definitions of <> and <> in 2.5.6. The terminology in both cases is "the appearance of the [entity] in a context requiring its... at that point." There is no controversy that, for example, a program containing an intrinsic assignment statement wherein and have different declared derived types is not standard conforming, even if the statement is never executed. EDITS: None. SUBMITTED BY: Aleksandar Donev HISTORY: J3/05-127 m171 Submitted