public inbox for
help / color / mirror / Atom feed
Subject: c++/10761: [3.4] wrong virtual function called
Date: Mon, 12 May 2003 23:16:00 -0000	[thread overview]
Message-ID: <> (raw)

>Number:         10761
>Category:       c++
>Synopsis:       [3.4] wrong virtual function called
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Mon May 12 23:16:01 UTC 2003
>Originator:     scott snyder
>Release:        3.4 20030512 (experimental)
<organization of PR author (multiple lines)>
System: Linux karma 2.4.19-emp_2419p5a829i #1 Tue Sep 3 17:42:17 EST 2002 i686 i686 i386 GNU/Linux
Architecture: i686

	<machine, os, target, libraries (multiple lines)>
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc/configure --prefix=/usr/local/gcc --enable-threads=posix --enable-long-long --enable-languages=c,c++,f77 : (reconfigured) 

Another case where we call the derived-class version of a virtual function,
in the face of an explicit request to call the version in the
base class.

The example below goes into an infinite recursive loop:

$ g++ -o x
$ ./x


extern "C" int printf(...);

class A
  virtual ~A () {}
  virtual void foo () { printf ("A::foo\n"); }

template <class T>
class B
  : public A
  virtual void foo () {
    printf ("B::foo\n");
    this->A::foo ();

int main ()
  B<int> b;;
  return 0;

	<how to correct or work around the problem, if known (multiple lines)>

             reply	other threads:[~2003-05-12 23:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-12 23:16 snyder [this message]
2003-05-13  5:36 Dara Hazeghi

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be 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).