public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Problem with gcc 2.96 - wrong virtual function call
@ 2002-01-18  8:55 Mateusz Kmiec
  2002-01-18  9:29 ` Claudio Bley
  0 siblings, 1 reply; 2+ messages in thread
From: Mateusz Kmiec @ 2002-01-18  8:55 UTC (permalink / raw)
  To: gcc-help

Hi,

I have the following problem with gcc 2.96:
I have an application that is compiled with egcs-2.91.66 and works on Red
Hat 7.2.
I am trying to change compiler from egcs (egcs-2.91.66) to gcc (gcc version
2.96 20000731).
I have changed all the code where it was neccessary.
It compiles now without warnings and links with gcc (as well as with old
egcs).

However my executable compiled with gcc does not work!!!!

When I debug it I can see it crashes on a wrong virtual function call.
I have a situation like this:

class A {
  virtual methodA() = 0;

...
};
class B
{
  virtual methodB() = 0;
...
};

class C: A , B
{
  virtual methodA();
  virtual methodB();
};

void main ()
{
	...
	A* pa = new A();
	...
	C* pc = pa;
	...

	pc->methodA(); // Wrong!!!!   methodB() is called
	...
}

This error is on gcc only.
Version compiled with egcs works correctly.

Is it a bug in gcc?
Please, if you've had a similar problem, tell me how I can avoid it.

thanks in advance Mateusz


==============================
 Mateusz Kmiec, programista
 e-mail: mateusz.kmiec@tpg.pl
------------------------------
 The Polished Group SA
 (+48 12) 424-14-00
 http://www.tpg.pl
==============================

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

* Re: Problem with gcc 2.96 - wrong virtual function call
  2002-01-18  8:55 Problem with gcc 2.96 - wrong virtual function call Mateusz Kmiec
@ 2002-01-18  9:29 ` Claudio Bley
  0 siblings, 0 replies; 2+ messages in thread
From: Claudio Bley @ 2002-01-18  9:29 UTC (permalink / raw)
  To: Mateusz Kmiec; +Cc: gcc-help

>>>>> "Mateusz" == Mateusz Kmiec <mateusz.kmiec@tpg.pl> writes:

    Mateusz> Hi, I have the following problem with gcc 2.96: I have an
    Mateusz> application that is compiled with egcs-2.91.66 and works
    Mateusz> on Red Hat 7.2.  I am trying to change compiler from egcs
    Mateusz> (egcs-2.91.66) to gcc (gcc version 2.96 20000731).  

I suggest you use a real gcc release such as gcc 3.0.3 -- gcc 2.96 has
been the code name for the GCC 3.0 development branch; and there are
of course errors which probably are already fixed in the current
release.

Claudio

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

end of thread, other threads:[~2002-01-18 17:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-18  8:55 Problem with gcc 2.96 - wrong virtual function call Mateusz Kmiec
2002-01-18  9:29 ` Claudio Bley

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).