------- Comment #10 from pault at gcc dot gnu dot org  2010-03-10 09:29 -------
In preparing a testcase, I foolishly decided to check the original for correct
execution.

The following gives the wrong result:
module m1
  type  :: t1
  contains 
    procedure :: sizeof
  end type
contains
  integer function sizeof(a)
    class(t1) :: a
    sizeof = 1
  end function sizeof
end module


module m2
  use m1
  type, extends(t1) :: t2    
  contains
    procedure :: sizeof => sizeof2
  end type
contains
  integer function sizeof2(a)
    class(t2) :: a
    sizeof2 = 2
  end function
end module


module m3
  use m2
  type :: t3
    class(t1), pointer  :: a 
  contains
    procedure :: sizeof => sizeof3
  end type
contains 
  integer function sizeof3(a)
    class(t3) :: a
    sizeof3 = a%a%sizeof()
  end function 
end module

  use m1
  use m2
  use m3
  class(t1), pointer :: a, ptr
  type(t1), target :: x
  type(t2), target :: y
  type(t3) :: z
  a => x
  print *, a%sizeof()
  a => y
  print *, a%sizeof()
  z%a => x
  print *, z%sizeof(), z%a%sizeof()
  z%a => y
  print *, z%sizeof(), z%a%sizeof()

end

gives
           1
           2
           1           1
           2           1

The last line should read
           2           2

of course.

The logic in calling resolve_class_compcall is wrong.

Paul


-- 


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

Reply via email to