🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #1209

A g++ bug in overloading in derived classes.

#1209
From: Nasser M. Khraishi
Date: Wed, 14 Oct 1992 06:24
45 lines
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.
}
----------
Technical Details
Message-ID: <9210142024.AA14054@ISL.Stanford.EDU>
Path: arc1-ca.pugleaf.net!sparky!uunet!think.com!rpi!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!isl.stanford.edu!khraishi

Show Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!think.com!rpi!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!isl.stanford.edu!khraishi
From: khraishi@isl.stanford.edu (Nasser M. Khraishi)
Subject: A g++ bug in overloading in derived classes.
Message-ID: <9210142024.AA14054@ISL.Stanford.EDU>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Wed, 14 Oct 1992 06:24:01 GMT
Approved: bug-gcc@prep.ai.mit.edu
Lines: 46