Thread View: gnu.gcc.bug
1 messages
1 total messages
Started by Nasser M. Khraishi
Wed, 14 Oct 1992 06:24
A g++ bug in overloading in derived classes.
Author: Nasser M. Khraishi
Date: Wed, 14 Oct 1992 06:24
Date: Wed, 14 Oct 1992 06:24
45 lines
1764 bytes
1764 bytes
Hello,
I ran into the following bug while porting a function to the SUN-CC2.1.
I initially thought that it is a CC2.1 problem (I trust your stuff a little
bit more) but after reading the ARM quite carefully it turns out that the
desirable response produced by g++ is actually the incorrect one.
The piece of code in question can be reduced to the equivalent of the
following code. I have included the explanation of the bug as a comment.
Best regards, and keep up the good work.
Nasser.
-------------
#include <iostream.h>
enum f1 {
F1
};
enum f2 {
F2
};
class A {
public:
void set (f1 f);
};
void A::set (f1 f) { cout << "called A f1\n";}
class B : public A {
public:
void set (f2 f);
};
void B::set (f2 f) { cout << "called B\n";}
main() {
B b;
b.set(F1); // ARM page 309: should call A.set(f1) and that what g++ does,
// but 13.1 of ARM clearly states that it should call B::set()
// or generate an error because overloading works only for
// functions within the same scope (first page of chapter 13)
// while member of derived and base classes are considered to
// belong to different scopes. Thus B::set() should have
// hidden (completely) the A::set() function.
}
----------
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads