llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.72k stars 11.88k forks source link

Incorrect overload resolution with volatile ref conversion operator #56604

Open steverobb opened 2 years ago

steverobb commented 2 years ago
void test(const int&); // 1
void test(volatile int&); // 2

struct X {
    operator volatile int&() const;
};

void func(const X& x) {
    test(x);
}

I don't believe 1 should ever be considered viable during overload resolution, yet Clang will error, claiming that overloads 1 and 2 are both viable candidates. Deleting 2 causes the compiler to correctly reject 1 as it would lose qualifiers.

llvmbot commented 2 years ago

@llvm/issue-subscribers-clang-frontend