This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/11570] New: incorrect behaviour in calling base class methods
- From: "OMS-sero dot Project at ict dot nl" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 Jul 2003 09:50:21 -0000
- Subject: [Bug c++/11570] New: incorrect behaviour in calling base class methods
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11570
Summary: incorrect behaviour in calling base class methods
Product: gcc
Version: 3.2.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: OMS-sero dot Project at ict dot nl
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: Cygwin PC with cross compiler
GCC target triplet: PowerPC
Dear mr. G.Nu,
I discovered some incorrect behaviour in calling base class methods inherited by
a derived class object. I enclosed the concerning files with this bug report,
that
specify the calls. It seems as if the offset to the called method is incorrecty
calculated. This is my situation that consists of three classes:
Menu::keyDownPressed()
{
// calls
gMenuLeft->isPresent();
}
class MenuDevice
{
public:
MenuDevice(){};
virtual ~MenuDevice(){};
//virtual bool isPresent()
virtual const bool isPresent() const {return true;};
virtual const sInt getValue(uInt id) const = 0;
};
class MenuLeft : public Menu,
public MenuDevice
{
// forced redefined from base class Menu
const uInt getCurrentAction();
// forced redefined from base class MenuDevice
const sInt getValue(uInt) const;
};
When I call "gMenuLeft->isPresent()" I don't end up in the "isPresent()" call
belonging
to "gMenuLeft", but in another call, actually the "getCurrentAction()" call.
Now I change the definition of the "MenuLeft" class to the following. Thus
change the
order of base class initialisation. Now when I call "gMenuLeft->isPresent()" I
also end
up in the "gMenuLeft->isPresent()" method. It looks as if the offset to the
method call is
calculated to the first defined base class, or so...
class MenuLeft : public MenuDevice,
public Menu
{
// forced redefined from base class Menu
const uInt getCurrentAction();
// forced redefined from base class MenuDevice
const sInt getValue(uInt) const;
};
We are using a Cygwin environment, with a GNU GCC cross compiler for a PowerPC
platform.
With kind regards,
M. Zuidhof
ICT Solution BV
The Netherlands