🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #887

Possible overloading bug with gcc 2.2.1

#887
From: Lewis G. Pringle
Date: Thu, 03 Sep 1992 04:57
38 lines
1672 bytes
//
//Possible problem with overloading in gcc 2.2.1.
// For what I belive is valid code we get the error message:
//x.cc: In function `int  f (class Derived*)':
//x.cc:30: in base initialization for class `BaseOwner',
//x.cc:30: invalid initializer to constructor for type `BaseOwner'
//x.cc:38: warning: control reaches end of non-void function


class	Base	{ int a; };
class	Derived : public Base { int b; };

class	BaseOwner {
	public:
		BaseOwner (Base* b);
};

class	TEST {
	public:
	TEST ();
	operator Derived* ();
};


int f (Derived* d)
{
	BaseOwner bo1 (d);		// Obviously this compiles
	Derived* d2 = TEST ();		// Not too surprising that this does too
	BaseOwner bo2 (d2);		// this is really just like the first test...
	BaseOwner b03 (TEST ());	// BUT: why does this not compile??
		// According to ARM 12.3.2 I get one user defined conversion
		// (and no more). This is Test::operator Derived* ().
		// And according to page 326 (13.2) "Standard Conversions
		// may be appled tothe argument for a user-defined conversion,
		// and to the result of the user defined conversion.". This would seem
		// to imply that the Derived* gets converted to a Base*, and so
		// the last line of code should compile.
}
Technical Details
Message-ID: <m0mQ9Fg-000AXWC@sophists.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!sophists.COM!lewis

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!sophists.COM!lewis
From: lewis@sophists.COM (Lewis G. Pringle)
Subject: Possible overloading bug with gcc 2.2.1
Message-ID: <m0mQ9Fg-000AXWC@sophists.com>
Sender: gnulists@ai.mit.edu
Reply-To: lewis@sophists.com
Organization: GNUs Not Usenet
Distribution: gnu
Date: Thu, 3 Sep 1992 04:57:00 GMT
Approved: bug-g++@prep.ai.mit.edu
Lines: 39