🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

BUG in G++ 1.36.1 - no error on non-ptr return from operator->()

#701
From: rfg
Date: Sun, 10 Dec 1989 00:28
31 lines
987 bytes
The language rules say that you cannot return non-pointer
values from operator->.  So why does G++ (1.36.1) wait until
it sees some *use* of a blatantly bogus declaration of an operator->
before it flags an error?

// rfg

struct c1 {
	int f1;
	int f2;

	c1 ();
	int get_f1 () { return f1; }
};

struct c2 {
	c1 c1_member;

	c1 & operator -> () { return c1_member; } // should get an error here!
};

int
main ()
{
	c2 c2_object;
	int i;

	i = c2_object->get_f1 ();    // actually gets an error here!
	i = c2_object->f1;           // actually gets an error here!
}
Technical Details
Message-ID: <8912091628.aa20121@ICS.UCI.EDU>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!ICS.UCI.EDU!rfg

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!ICS.UCI.EDU!rfg
From: rfg@ICS.UCI.EDU
Newsgroups: gnu.g++.bug
Subject: BUG in G++ 1.36.1 - no error on non-ptr return from operator->()
Message-ID: <8912091628.aa20121@ICS.UCI.EDU>
Date: 10 Dec 89 00:28:09 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 31