This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Bogus name lookup by overloaded operators


The gcc 2.95.2 seems to mix up the unary and binary operators during name
lookup.


#line 1 "prob10.cc"
class A {
public:
   void operator* () const;
};

class B {
public:
   void operator* () const;
};

class C : public A, public B { };

void operator* (const C&, const C&) { }

int main()
{
   C c1, c2;
   c1*c2;
   return 0;
}


prob10.cc: In function `int main()':
prob10.cc:18: request for member `operator *' is ambiguous
prob10.cc:8: candidates are: void B::operator *() const
prob10.cc:3:                 void A::operator *() const


I've already started to doubt that these operators should be treated as
lexically distinct, but then found a similar example in the Standard,
par. 13.3.1.2.10. Thus I consider it's yet a bug.

The system enviroment was as follows:

% uname -a
SunOS sokol 5.7 Generic_106541-08 sun4u sparc SUNW,UltraSPARC-IIi-Engine

% g++ -v
Using builtin specs.
gcc version 2.95.2 19991024 (release)

% cat tmp/gcc-build/config.status 
#!/bin/sh
# This file was generated automatically by configure.  Do not edit.
# This directory was configured as follows:
.../tmp/gcc-2.95.2/configure --with-gcc-version-trigger=.../tmp/gcc-2.95.2/gcc/version.c --host=sparc-sun-solaris2.6 --enable-shared --enable-version-specific-runtime-libs --enable-languages=c++ --with-gxx-include-dir=/usr/local/include/C++ --norecursion 
# using "mh-frag" and "mt-frag"


With best regards,
Ewgenij Gawrilow
Dept. of Mathematics, Technical University of Berlin

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]