🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by rfg Sun, 10 Dec 1989 00:28
BUG in G++ 1.36.1 - no error on non-ptr return from operator->()
#701
Author: 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!
}
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