This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

c++/9415: g++ 3.4: can't call base class's virtual function


>Number:         9415
>Category:       c++
>Synopsis:       g++ 3.4: can't call base class's virtual function
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          wrong-code
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 23 07:06:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     scott snyder
>Release:        3.4 20030121 (experimental)
>Organization:
<organization of PR author (multiple lines)>
>Environment:
System: Linux karma 2.4.19-emp_2419p5a829i #1 Tue Sep 3 17:42:17 EST 2002 i686 unknown
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
>Description:

In the program below, the call to d0_Object::activate() does not call
the method requested.  Instead, it does a virtual call to activate() ---
meaning that this program, when run, goes into an infinite recursion.
If i change it so that d0_DBObject is not a template class, then the
program behaves as expected.

$ g++ -o x x.cc
$ ./x
act
act
act
act
act
act
act
... and so on ...

>How-To-Repeat:

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

struct d0_Object
{
  virtual void activate() {}
};

template <class K>
struct d0_DBObject : public d0_Object
{
  void activate() { printf ("act\n"); d0_Object::activate();}
};

int main ()
{
  d0_DBObject<int> x;
  x.activate();
  return 0;
}
----------------------

>Fix:
	<how to correct or work around the problem, if known (multiple lines)>
>Release-Note:
>Audit-Trail:
>Unformatted:


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]