Implicit assignment operator hidden by overloaded assignement operator?

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

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.

This seems to be a bug; please file it.

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.

The parameter of the implicit copy-assignment operator is being bound to a temporary B object built with the appropriate constructor. This is correct.

John.

Done: http://llvm.org/bugs/show_bug.cgi?id=6570

Andrzej