(j3.2006) Whose bug is it?

Craig Dedo craig
Wed Mar 5 09:23:01 EST 2008


Everyone:
	It appears that the use of module M2 in the internal procedure masks
the definitions in module M1 in the main program.  My reasoning is based on
the text of 04-007, the last free version of the Fortran 2003 standard.

	Use association is defined in section 11.2.1.  Host association is
covered in section 16.4.1.3.  The second paragraph starts with this sentence
[411:9-10]:  "If an entity that is accessed by use association has the same
nongeneric name as a host entity, the host entity is inaccessible by that
name."

	The definitions in M1 are part of the scoping unit of PROGRAM MAIN.
Thus, they are accessible by host association to the internal subroutine S,
along with all of the entities that are defined in PROGRAM MAIN itself.  The
definitions in M2 are accessible to SUBROUTINE S by use association.  If
there is a name in module M2 that has the same name as anything in PROGRAM
MAIN, then the name in PROGRAM MAIN is inaccessible in SUBROUTINE S.  

	Admittedly, the normative text of the standard does not directly
address the issue of the interaction of use association and host association
inside of internal procedures.  However, I believe my reasoning is correct,
given the existing normative text of the relevant passages in the Fortran
2003 standard.

	Comments, anyone?

Sincerely,
Craig Dedo
17130 W. Burleigh Place
P. O. Box 423                       Voice Phone:? (262) 783-5869
Brookfield, WI?? 53008-0423? Fax Phone:? (262) 783-5928
USA???????????????????????????????????? Mobile Phone:? (414) 412-5869
E-mail:? <cdedo at wi.rr.com> or <craig at ctdedo.com> 

-----Original Message-----
From: j3-bounces at j3-fortran.org [mailto:j3-bounces at j3-fortran.org] On Behalf
Of Robert Corbett
Sent: Wednesday, March 05, 2008 01:04
To: fortran standards email list for J3
Subject: (j3.2006) Whose bug is it?

A user claims that of all the Fortran 95 compilers he has tried,
and he has a list, only Sun Fortran fails to compile the following
program:

       MODULE M1
         INTERFACE SUBR
           MODULE PROCEDURE SUBR1
         END INTERFACE
       CONTAINS
         SUBROUTINE SUBR1
         END SUBROUTINE
       END

       MODULE M2
         INTERFACE SUBR
           MODULE PROCEDURE SUBR2
         END INTERFACE
       CONTAINS
         SUBROUTINE SUBR2
         END SUBROUTINE
       END

       PROGRAM MAIN
         USE M1
         CALL S
       CONTAINS
         SUBROUTINE S
           USE M2
           CALL SUBR
         END SUBROUTINE
       END

Sun Fortran does fail to compile the program.  It gives the error
message

        USE M1
             ^
"test.f", Line = 20, Column = 6: ERROR: The specific interfaces for 
"SUBR1" and "SUBR2" make the GENERIC interface "SUBR" ambiguous.

The user seems to think that the definition imported by the USE
statement in the internal subroutine S should override the definition
imported by the USE statement that appears directly in the main
program.  I think he is wrong.  Am I overlooking something?

Bob Corbett
_______________________________________________
J3 mailing list
J3 at j3-fortran.org
http://j3-fortran.org/mailman/listinfo/j3






More information about the J3 mailing list