Reported by Arjen Markus.
http://gcc.gnu.org/ml/fortran/2008-09/msg00327.html

The following program causes an ICE ("insert_bbt(): Duplicate key found!") when
compiled with gfortran 4.1 to 4.4.

a) The unmodified program seems to be invalid as NAG f95 and ifort show:
  Error: ENTRY point GLOCAL is not in a RECURSIVE function
  error #6437: A subroutine or function is calling itself recursively. [GLOCAL]
I believe the error message is correct (cf. quote from F2003 below).
-> accepts-invalid/diagnostic bug

b) With recursive, Lahey, NAG f95 and ifort compile the program without
errors/warnings.
-> ICE-on-valid-code

module gsub
contains
subroutine sub( g )   ! prefix with "RECURSIVE"
   interface
       real function g(x)
       real x
       end function
   end interface
   real :: x, y
   call mysub( glocal )
   return
entry glocal( x, y )
   y = x
end subroutine
end module


Regarding RECURSIVE, Fortran 2003 has:

"The prefix-spec RECURSIVE shall appear if the function directly or indirectly
invokes itself or a function defined by an ENTRY statement in the same
subprogram. Similarly, RECURSIVE shall appear if a function defined by an ENTRY
statement in the subprogram directly or indirectly invokes itself, another
function defined by an ENTRY statement in that subprogram, or the function
defined by the FUNCTION statement." (12.5.2.1, analogously in 12.5.2.2)


-- 
           Summary: ICE "insert_bbt(): Duplicate key" for self-calling ENTRY
                    subprogram
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: ice-on-valid-code, accepts-invalid, diagnostic
          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=37583

Reply via email to