After a fresh fortran-dev checkout, configure, make, and make install, the
first two modules below compile correctly, while the third produces the the
compile-time errors shown.  The two offending lines are the "allocate"
statement and the subsequent pointer assignment, both in the "new_bar"
function.  Based on the error message, this is related to vtabs.  Apparently
the error is platform-dependent since Janus reports compiling similar code with
no problem.

Damian

$ cat foo.f03 
module foo_module
  implicit none
  type foo 
  end type
end module

$ cat bar.f03 
module bar_module
  use foo_module
  implicit none
  type ,extends(foo) :: bar
  end type
contains
  function bar_()
    type(bar) ,pointer :: bar_ 
    bar_ => null()
  end function
end module

$ cat bar_factory.f03 
module bar_factory_module
  implicit none
  type bar_factory
  contains 
    procedure :: new_bar
  end type 
contains
  function new_bar(this) 
    use bar_module
    use foo_module 
    class(bar_factory), intent(in) :: this
    class(foo) ,pointer :: new_bar
    allocate(bar :: new_bar)
    new_bar => bar_() 
  end function
end module

$ gfortran -c foo.f03
$ gfortran -c bar.f03
$ gfortran -c bar_factory.f03 
/var/folders/aN/aNwnamXwF00CoxUk5fEVmU+++TM/-Tmp-//cciAcMyX.s:37:non-relocatable
subtraction expression, "_vtab$bar.1525" minus "L00000000001$pb"
/var/folders/aN/aNwnamXwF00CoxUk5fEVmU+++TM/-Tmp-//cciAcMyX.s:37:symbol:
"_vtab$bar.1525" can't be undefined in a subtraction expression
/var/folders/aN/aNwnamXwF00CoxUk5fEVmU+++TM/-Tmp-//cciAcMyX.s:35:non-relocatable
subtraction expression, "_vtab$bar.1525" minus "L00000000001$pb"
/var/folders/aN/aNwnamXwF00CoxUk5fEVmU+++TM/-Tmp-//cciAcMyX.s:35:symbol:
"_vtab$bar.1525" can't be undefined in a subtraction expression


-- 
           Summary: Compile-time errors on typed allocation and pointer
                    function result assignment
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: damian at rouson dot net
 GCC build triplet: Mac OS X 10.5.8
  GCC host triplet: Mac OS X 10.5.8
GCC target triplet: Mac OS X 10.5.8


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

Reply via email to