public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/33542]  New: gfortran does not detect ambigious specific names if they are the same as generic names
@ 2007-09-24  9:06 burnus at gcc dot gnu dot org
  2007-09-24 20:55 ` [Bug fortran/33542] " burnus at gcc dot gnu dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-09-24  9:06 UTC (permalink / raw)
  To: gcc-bugs

Found at
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/1abc1549a6a164f1/

One should re-check it as only g95 and Portland reject it whereas Pathscale,
gfortran, ifort, sunf95,openf95 and especially NAG f95 and Lahey accept it.

The following program is obviously wrong as one tries to pass an generic name
as actual argument, which is not possible as only specific names are allow.
gfortran and the other compilers properly diagnose:

Error: GENERIC non-INTRINSIC procedure 'foo' is not allowed as an actual
argument at (1)

for the following program:

MODULE M1
   INTERFACE FOO
     MODULE PROCEDURE FOO2
   END INTERFACE
CONTAINS
   SUBROUTINE FOO2(I)
     INTEGER, INTENT(IN) :: I
     WRITE(*,*) 'INTEGER'
   END SUBROUTINE FOO2
END MODULE M1

MODULE M2
   INTERFACE FOO
     MODULE PROCEDURE FOO2
   END INTERFACE
CONTAINS
   SUBROUTINE FOO2(R)
     REAL, INTENT(IN) :: R
     WRITE(*,*) 'REAL'
   END SUBROUTINE FOO2
END MODULE M2

PROGRAM P
   USE M1
   USE M2
   implicit none
   external bar
   CALL FOO(10)
   CALL FOO(10.)
   CALL BAR(foo) ! <<<< error needs specific interface
END PROGRAM P

The fun starts if the generic interface FOO has the same name as the specific
interfaces in each of the modules. Most compilers allow now this code although
it is ambiguous: Which of the two specific functions has to be used as actual
argument?

g95 and Portland reject the program as soon as any "foo" is used; the real
ambiguity is, however, only the FOO in "call BAR". Though probably any usage of
FOO should be rejected. (We need to check this carefully.)

Example, rejected by g95 and Portland, accepted by gfortran, NAG f95 etc.:

MODULE M1
   INTERFACE FOO
     MODULE PROCEDURE FOO
   END INTERFACE
CONTAINS
   SUBROUTINE FOO(I)
     INTEGER, INTENT(IN) :: I
     WRITE(*,*) 'INTEGER'
   END SUBROUTINE FOO
END MODULE M1

MODULE M2
   INTERFACE FOO
     MODULE PROCEDURE FOO
   END INTERFACE
CONTAINS
   SUBROUTINE FOO(R)
     REAL, INTENT(IN) :: R
     WRITE(*,*) 'REAL'
   END SUBROUTINE FOO
END MODULE M2

PROGRAM P
   USE M1
   USE M2
   implicit none
   external bar
   CALL FOO(10)
   CALL FOO(10.)
   CALL BAR(foo)
END PROGRAM P


-- 
           Summary: gfortran does not detect ambigious specific names if
                    they are the same as generic names
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33542


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2007-10-14 19:27 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-24  9:06 [Bug fortran/33542] New: gfortran does not detect ambigious specific names if they are the same as generic names burnus at gcc dot gnu dot org
2007-09-24 20:55 ` [Bug fortran/33542] " burnus at gcc dot gnu dot org
2007-09-30 16:53 ` pault at gcc dot gnu dot org
2007-10-02 10:05 ` dominiq at lps dot ens dot fr
2007-10-02 11:45 ` pault at gcc dot gnu dot org
2007-10-02 11:47 ` pault at gcc dot gnu dot org
2007-10-04  4:46 ` pault at gcc dot gnu dot org
2007-10-04  4:49 ` pault at gcc dot gnu dot org
2007-10-07 19:05 ` patchapp at dberlin dot org
2007-10-12 16:52 ` pault at gcc dot gnu dot org
2007-10-14 19:27 ` pault at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).