public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/11750] New: Incorrect virtual method invoked for class hierarchy w/ virtual bases
@ 2003-07-31 17:44 jfischer_5809 at yahoo dot com
2003-08-01 19:10 ` [Bug c++/11750] " pinskia at physics dot uc dot edu
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: jfischer_5809 at yahoo dot com @ 2003-07-31 17:44 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11750
Summary: Incorrect virtual method invoked for class hierarchy w/
virtual bases
Product: gcc
Version: 3.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jfischer_5809 at yahoo dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
Paragraph 10.3/2 in the C++ standard [ISO/IEC 14882:1998] provides the following
code example:
<quote>
struct A {
virtual void f();
};
struct B : virtual A {
virtual void f();
};
struct C : B , virtual A {
using A::f;
};
void foo() {
C c;
c.f(); // calls B::f, the final overrider
c.C::f(); // calls A::f because of the using-declaration
}
</quote>
When a similar program is compiled using G++ 3.3, the method call 'c.f()' in
function foo() incorrectly invokes A::f and not B::f as specified in the standard.
<example>
<code main.cpp>
#include <iostream>
struct A {
virtual void f() { std::cout << "A::f()\n"; }
};
struct B : virtual A {
virtual void f() { std::cout << "B::f()\n"; }
};
struct C : B, virtual A {
using A::f;
};
int main()
{
C c;
c.f(); // ERROR - Incorrectly invokes A::f
c.C::f(); // OK - Invokes A::f
}
</code>
<build>
$ g++ main.cpp
$ ldd a.out
libstdc++.so.5 =>
/usr/local/gcc/3.3/lib/gcc-lib/i686-pc-linux-gnu/3.3/libstdc++.so.5 (0x40017000)
libm.so.6 => /lib/tls/libm.so.6 (0x400e4000)
libgcc_s.so.1 =>
/usr/local/gcc/3.3/lib/gcc-lib/i686-pc-linux-gnu/3.3/libgcc_s.so.1 (0x40106000)
libc.so.6 => /lib/tls/libc.so.6 (0x42000000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
</build>
<output>
$ ./a.out
A::f()
A::f()
</output>
</example>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/11750] Incorrect virtual method invoked for class hierarchy w/ virtual bases
2003-07-31 17:44 [Bug c++/11750] New: Incorrect virtual method invoked for class hierarchy w/ virtual bases jfischer_5809 at yahoo dot com
@ 2003-08-01 19:10 ` pinskia at physics dot uc dot edu
2003-08-23 1:03 ` dhazeghi at yahoo dot com
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at physics dot uc dot edu @ 2003-08-01 19:10 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11750
pinskia at physics dot uc dot edu changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Keywords| |wrong-code
Last reconfirmed|0000-00-00 00:00:00 |2003-08-01 19:10:34
date| |
------- Additional Comments From pinskia at physics dot uc dot edu 2003-08-01 19:10 -------
I can confirm this on the mainline (20030801).
ICC 6.0 produces the correct ouput.
Note 2.95.3 produces:
B::f()
B::f()
While 3.0.4 produces:
A::f()
A::f()
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/11750] Incorrect virtual method invoked for class hierarchy w/ virtual bases
2003-07-31 17:44 [Bug c++/11750] New: Incorrect virtual method invoked for class hierarchy w/ virtual bases jfischer_5809 at yahoo dot com
2003-08-01 19:10 ` [Bug c++/11750] " pinskia at physics dot uc dot edu
@ 2003-08-23 1:03 ` dhazeghi at yahoo dot com
2004-08-05 23:18 ` davi at ppgia dot pucpr dot br
2004-08-08 16:33 ` giovannibajo at libero dot it
3 siblings, 0 replies; 5+ messages in thread
From: dhazeghi at yahoo dot com @ 2003-08-23 1:03 UTC (permalink / raw)
To: gcc-bugs
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11750
dhazeghi at yahoo dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|3.4 |---
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/11750] Incorrect virtual method invoked for class hierarchy w/ virtual bases
2003-07-31 17:44 [Bug c++/11750] New: Incorrect virtual method invoked for class hierarchy w/ virtual bases jfischer_5809 at yahoo dot com
2003-08-01 19:10 ` [Bug c++/11750] " pinskia at physics dot uc dot edu
2003-08-23 1:03 ` dhazeghi at yahoo dot com
@ 2004-08-05 23:18 ` davi at ppgia dot pucpr dot br
2004-08-08 16:33 ` giovannibajo at libero dot it
3 siblings, 0 replies; 5+ messages in thread
From: davi at ppgia dot pucpr dot br @ 2004-08-05 23:18 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From davi at ppgia dot pucpr dot br 2004-08-05 23:18 -------
A way to workaround this is to put C into the heap. Is anyone going to fix this ?
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11750
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c++/11750] Incorrect virtual method invoked for class hierarchy w/ virtual bases
2003-07-31 17:44 [Bug c++/11750] New: Incorrect virtual method invoked for class hierarchy w/ virtual bases jfischer_5809 at yahoo dot com
` (2 preceding siblings ...)
2004-08-05 23:18 ` davi at ppgia dot pucpr dot br
@ 2004-08-08 16:33 ` giovannibajo at libero dot it
3 siblings, 0 replies; 5+ messages in thread
From: giovannibajo at libero dot it @ 2004-08-08 16:33 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From giovannibajo at libero dot it 2004-08-08 16:33 -------
(In reply to comment #2)
> Is anyone going to fix this ?
I doubt it, at least any time soon. This is not a regression, and our semantic
of the using declarations should be reworked (right now, they match old ARM-
style access declarations).
If you feel strong about this, you can either try to look into the problem
yourself, or hire someone to do the work.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11750
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2004-08-08 16:33 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-07-31 17:44 [Bug c++/11750] New: Incorrect virtual method invoked for class hierarchy w/ virtual bases jfischer_5809 at yahoo dot com
2003-08-01 19:10 ` [Bug c++/11750] " pinskia at physics dot uc dot edu
2003-08-23 1:03 ` dhazeghi at yahoo dot com
2004-08-05 23:18 ` davi at ppgia dot pucpr dot br
2004-08-08 16:33 ` giovannibajo at libero dot it
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).