Overloaded operator preference

Viewed 56

Which of the two operators the compiler must prefer here?

#include <iostream>

struct A
{
    operator char() { return 'A'; }
};

struct B : A
{
    operator auto() { return 'B'; }
};

int main()
{
    std::cout << B().operator char();
}

Clang prints A and GCC prints B: https://gcc.godbolt.org/z/v6c5Ta9Mf

0 Answers
Related