public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/43326]  New: [OOP] dynamic dispatch with CLASS components
@ 2010-03-10 21:02 janus at gcc dot gnu dot org
  2010-03-10 22:06 ` [Bug fortran/43326] " janus at gcc dot gnu dot org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: janus at gcc dot gnu dot org @ 2010-03-10 21:02 UTC (permalink / raw)
  To: gcc-bugs

Spin-off from PR 43291 comment #10 ...

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.


-- 
           Summary: [OOP] dynamic dispatch with CLASS components
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: janus at gcc dot gnu dot org


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


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2010-04-29 19:12 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-10 21:02 [Bug fortran/43326] New: [OOP] dynamic dispatch with CLASS components janus at gcc dot gnu dot org
2010-03-10 22:06 ` [Bug fortran/43326] " janus at gcc dot gnu dot org
2010-03-10 22:50 ` janus at gcc dot gnu dot org
2010-03-12 22:01 ` pault at gcc dot gnu dot org
2010-04-20 12:22 ` dominiq at lps dot ens dot fr
2010-04-20 12:26 ` [Bug fortran/43326] [fortran-dev Regression] " janus at gcc dot gnu dot org
2010-04-20 18:58 ` pault at gcc dot gnu dot org
2010-04-20 19:17 ` dominiq at lps dot ens dot fr
2010-04-21  4:53 ` pault at gcc dot gnu dot org
2010-04-21 14:29 ` pault at gcc dot gnu dot org
2010-04-21 16:50 ` pault at gcc dot gnu dot org
2010-04-21 16:51 ` pault at gcc dot gnu dot org
2010-04-21 17:09 ` dominiq at lps dot ens dot fr
2010-04-29 19:12 ` pault at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).