[gnu.g++.bug] BUG in G++ 1.34.1

rfg@MCC.COM (Ron Guilmette) (03/31/89)

The following program contains apparently legal code, but g++ 1.34.1
(on a Sun3) rejects it with compile-time errors.

----------------------------------------------------------------------
// Check that it is legal to take the address of an overloaded
// operator (which is class-name-qualified), even if that operator
// could be either a unary or a binary operator, so long as the
// operator designator is unambiguous when class-name-qualified
// (i.e. only one form is declared for the class).
//
// Note that the & operator may be applied to unambiguous qualified
// method names.  It seems that this privledge should extend likewise
// to unambigous qualified operator designators.

#include "Testinc.h"

class base {
	int field;
public:
	int operator+ (base b);
	int operator- ();
};

int test ()
{
	&base::operator+;	// compile-time error using g++ 1.34.1
	&base::operator-;	// compile-time error using g++ 1.34.1
	return 0;
}

int base::operator+ (base b)
{
	b.field = 7;
	return 0;
}

int base::operator- ()
{
	return 0;
}
------------------------------------------------------------------------
g++ -Wall -Wwrite-strings -v -S a023.C
g++ version 1.34.1.1
 /usr/local/src/lib/sun3/g++-1.34.1.1/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -Wall -D__HAVE_68881__ -Dmc68020 a023.C /tmp/cca02641.cpp
GNU CPP version 1.34.1.1
 /usr/local/src/lib/sun3/g++-1.34.1.1/gcc-c++ /tmp/cca02641.cpp -quiet -dumpbase a023.C -Wall -Wwrite-strings -noreg -version -o a023.s
GNU C++ version 1.34.1.1 (68k, MIT syntax) compiled by GNU C version 1.33.
In function int test ():
a023.C:22: invalid lvalue in unary `&'
a023.C:23: invalid lvalue in unary `&'

rfg@MCC.COM (Ron Guilmette) (04/15/89)

G++ 1.34.1 issues no errors for the (obviously) ambiguous reference
to an overloaded function name (as shown below).

This is on a Sun3/SunOS-3.5.

------------------------------------------------------------------------
overload function;
overload function_of_function;

void function (char c);
void function (float f);

typedef void (*ptr_to_function_of_char)(char);
typedef void (*ptr_to_function_of_float)(float);

void function_of_function (ptr_to_function_of_float);
void function_of_function (ptr_to_function_of_char);


int test ()
{
	function_of_function (function);	// ERROR - ambiguous
}
------------------------------------------------------------------------

// Ron Guilmette  -  MCC  -  Experimental Systems Kit Project
// 3500 West Balcones Center Drive,  Austin, TX  78759  -  (512)338-3740
// ARPA: rfg@mcc.com
// UUCP: {rutgers,uunet,gatech,ames,pyramid}!cs.utexas.edu!pp!rfg