public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/53255] New: [OOP] With TYPE, wrong type-bound operator used: of parent instead of overridden one Date: Sun, 06 May 2012 08:55:00 -0000 [thread overview] Message-ID: <bug-53255-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53255 Bug #: 53255 Summary: [OOP] With TYPE, wrong type-bound operator used: of parent instead of overridden one Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned@gcc.gnu.org ReportedBy: burnus@gcc.gnu.org Reported by Reinhold Bader. Expected: The following output: executing base executing override OK De-facto output: executing base executing base FAIL If one changes: type(ext) :: p to class(ext), allocatable :: p allocate(p) or class(base), allocatable :: p allocate(ext :: p) it works. Thus, it seems as if only the compile-time resolution of TYPE has the problem, while the vtable run-time version is correct. module mod_base implicit none private type, public :: base private real :: r(2,2) = reshape( (/ 1.0, 2.0, 3.0, 4.0 /), (/ 2, 2 /)) contains procedure, private :: trace generic :: operator(.tr.) => trace end type base contains complex function trace(this) class(base), intent(in) :: this trace = this%r(1,1) + this%r(2,2) end function trace end module mod_base module mod_ext use mod_base implicit none private public :: base type, public, extends(base) :: ext private real :: i(2,2) = reshape( (/ 1.0, 1.0, 1.0, 1.5 /), (/ 2, 2 /)) contains procedure, private :: trace => trace_ext end type ext contains complex function trace_ext(this) class(ext), intent(in) :: this ! the following should be executed through invoking .tr. p below write(*,*) 'executing override' trace_ext = .tr. this%base + (0.0, 1.0) * ( this%i(1,1) + this%i(2,2) ) end function trace_ext end module mod_ext program test_override use mod_ext implicit none type(base) :: o type(ext) :: p ! write(*,*) .tr. o ! write(*,*) .tr. p if (abs(.tr. o - 5.0 ) < 1.0e-6 .and. abs( .tr. p - (5.0,2.5)) < 1.0e-6) then write(*,*) 'OK' else write(*,*) 'FAIL' end if end program test_override
next reply other threads:[~2012-05-06 8:09 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-05-06 8:55 burnus at gcc dot gnu.org [this message] 2012-05-06 10:33 ` [Bug fortran/53255] " burnus at gcc dot gnu.org 2012-05-07 8:44 ` burnus at gcc dot gnu.org 2012-05-07 11:52 ` burnus at gcc dot gnu.org 2012-05-07 13:35 ` burnus at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-53255-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).