[cfe-dev] Implicit assignment operator hidden by overloaded assignement operator?

Andrzej K. Haczewski ahaczewski at gmail.com
Tue Mar 9 14:33:58 PST 2010


Hi,

Trying to compile Ogre3D with clang I believe I found a bug. The
reduced test case looks like this:

class A {
};

class B {
public:
	B() {}

	B(const A& a) {
		operator = (CONST);
		operator = (a);
	}
	
	B& operator = (const A& a) {
		return *this;
	}
	
	static const B CONST;
};

The clang output is:

t3.cc:13:15: error: no viable conversion from 'class B const' to 'class A const'
                operator = (CONST);
                            ^~~~~
t3.cc:1:7: note: candidate constructor (the implicit copy constructor)
not viable: no known conversion from 'class B const' to 'class A
const' for 1st argument
class A {
      ^
2 diagnostics generated.

If you remove the overloaded operator = then everything compiles,
which is another strange behaviour, because there should be no
implicit class A to class B conversion.

Should I submit it as bugs or are these known ones?

Regards,
Andrzej



More information about the cfe-dev mailing list