The testcase below leads to the following linker error on current trunk, gcc
4.5.0 and gcc 4.5.1: 
$gfortran fails.f90
/tmp/ccG09ce7.o: In function `__fails_test_MOD_bar':
fails.f90:(.text+0xe): undefined reference to `vtab$b_t.1500'
collect2: ld returned 1 exit status

The patch at the end of the bug report seems to solve the problem for me but
it's mainly a wild guess. The issue seems to be closely related to 44065.

file fails.f90
module fails_mod
  implicit none 
  type :: a_t
     integer :: a
  end type
  type, extends(a_t) :: b_t
     integer :: b
  end type
  subroutine foo(a)
    class(a_t) :: a
  end subroutine foo
end module fails_mod

module fails_test
  implicit none
  subroutine bar
    use fails_mod
    type(b_t) :: b
    call foo(b)
  end subroutine bar
end module fails_test


Index: fortran/interface.c
--- fortran/interface.c (revision 164288)
+++ fortran/interface.c (working copy)
@@ -1428,10 +1428,12 @@
       && actual->ts.u.derived && actual->ts.u.derived->ts.is_iso_c)
     return 1;

-  if (formal->ts.type == BT_CLASS)
+  if (formal->ts.type == BT_CLASS) {
     /* Make sure the vtab symbol is present when
        the module variables are generated.  */
     gfc_find_derived_vtab (formal->ts.u.derived);
+    gfc_find_derived_vtab (actual->ts.u.derived);
+  }

   if (actual->ts.type == BT_PROCEDURE)

           Summary: [OOP] Undefined references for extended types
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: dietmar dot ebner at gmail dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu

Reply via email to