8

The following is compiled fine by gcc (12.1 and trunk), but clang (14.0.0 and trunk) gives an error on d.foo(), saying the call is ambiguous. Question is, to which compiler should I report a bug?

class Base
{
public:
  void foo() {}
};

class Derived: public Base
{
public:
  using Base::foo;
  void foo() & {}
};

int main()
{
  Derived d;

  // Clang says here: error: call to member function 'foo' is ambiguous. Gcc,
  // however, is fine with it
  d.foo();

  return 0;
}
dragonroot
  • 5,653
  • 3
  • 38
  • 63
  • 1
    Does this answer your question? [Why is overloading on just one ref-qualifier not allowed?](https://stackoverflow.com/questions/35389911/why-is-overloading-on-just-one-ref-qualifier-not-allowed) – kotatsuyaki Jun 06 '22 at 05:25
  • @kotatsuyaki There's no overloading here, so I don't think so. Here the new declaration of `foo` is either supposed to shadow the old one, or not – dragonroot Jun 06 '22 at 05:35
  • 2
    I have found another duplicate that's closer to this question: [Overloading a parent member function without ref-qualifier with a child member function with ref-qualifier in C++](https://stackoverflow.com/q/70015603/12122460) – kotatsuyaki Jun 06 '22 at 05:41
  • Appears so, yes, but it unfortunately doesn't answer my main question - which compiler is actually wrong, and I'd rather report the bug – dragonroot Jun 06 '22 at 05:45

0 Answers0