🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

g++ 2.2.1 bug with overloading

#940
From: Lewis G. Pringle
Date: Wed, 09 Sep 1992 00:40
43 lines
1962 bytes
// This code compiles fine when ShowBug is 0, but if set to 1, then we get the
// error message:
//	fred.cc: In function `void  Normalize (const struct String&)':
//	fred.cc:42: assignment not defined for type `CircularArrayNodeOfString'
// compiling using:
//	g++ -c fred.cc; with gcc 2.2.1
//
// According to ARM 12.8 (page 295) [refering to assignment operators and
// copy constructors] "The programmer may define one or both of these. If not
// defined by the programmer, they will be defined as memberwise assignment and
// memberwise initialization of the members of X, respectively"
//
// Given this definition, how overloading takes place should not be effected
// by whether or not I define this operator. That is the first bug. Secondly,
// The line 42 below which fails to compile (when ShowBug is 1) should compile
// correctly because it involves only 1 user-defined conversion (String->CircularArrayNodeOfString).



#define	ShowBug	1
struct	String {
	String (const String& from);
	~String ();

 	String&	operator= (const String& newString);
};

struct	CircularArrayNodeOfString    { 
	CircularArrayNodeOfString  (String item): fItem (item)	{}
	~CircularArrayNodeOfString ()				{}
#if	!ShowBug
	CircularArrayNodeOfString&	operator= (const CircularArrayNodeOfString&);
#endif
	String	fItem;
};

void	Normalize (const String& a)
{
	CircularArrayNodeOfString aa (a);

	aa = CircularArrayNodeOfString (a);	// works fine
/*42*/	aa = a;					// should involve just 1 user-defined conversion, and be OK?
}
Technical Details
Message-ID: <m0mSG6g-000AWzC@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: g++ 2.2.1 bug with overloading
Message-ID: <m0mSG6g-000AWzC@sophists.com>
Sender: gnulists@ai.mit.edu
Reply-To: lewis@sophists.com
Organization: GNUs Not Usenet
Distribution: gnu
Date: Wed, 9 Sep 1992 00:40:00 GMT
Approved: bug-g++@prep.ai.mit.edu
Lines: 45