This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gfortran 4.6 crashes with a type-bound procedure that overloads .LT.


Greetings All,

I have run into erratic behavior trying to compile a module that defines
a derived type with a component that is, in turn, another derived type
that has a type-bound relational operator (.LT.).  Depending on the
specifics, I sometimes get a compiler crash and sometimes successful
completion, but wrong code.  Near-minimal code that produces a crash is
copied below.

Module DEF1 compiles OK.  But subsequently trying to compile module MESH
produces:

f951:  internal compiler error: in gfc_add_component_ref, at
fortran/class.c:77

The problem seems to be the line

LST = (A%PT .LT. B%PT) 

in module MESH, which invokes the overloaded .LT. defined in module
DEF1.

I am running gfortran 4.6, specifically the Sept. 24 build.

Any help or insight would be much appreciated!

Mark Rashid

Here is the code:

      MODULE DEF1
C
      TYPE :: DAT
        INTEGER :: NN
        REAL :: XYZ(3)
        CONTAINS
        PROCEDURE :: LESS_THAN
        GENERIC :: OPERATOR (.LT.) => LESS_THAN
      END TYPE DAT
C
      CONTAINS
C
      FUNCTION LESS_THAN(A, B)
C
        CLASS (DAT), INTENT (IN) :: A, B
        LOGICAL :: LESS_THAN
C
        LESS_THAN = (A%NN .LT. B%NN)
C
        RETURN
      END FUNCTION LESS_THAN
C
      END MODULE DEF1

=============================================================

      MODULE MESH
C
      USE DEF1
C
      TYPE NODE
        INTEGER :: KEY
        CLASS (DAT), POINTER :: PT
        CONTAINS
        PROCEDURE :: LST
        GENERIC :: OPERATOR (.LT.) => LST
      END TYPE NODE
C
      CONTAINS
C
      FUNCTION LST (A, B)
C
        CLASS (NODE), INTENT (IN) :: A, B
        LOGICAL :: LST
C
        IF (A%KEY .GT. 0 .AND. B%KEY .GT. 0) THEN
          LST = (A%KEY .LT. B%KEY)
        ELSE
          LST = (A%PT .LT. B%PT)
        END IF
C
        RETURN
      END FUNCTION LST
C
      END MODULE MESH



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]