llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Error when taking address of overloaded conversion function, with only one non-template overload

Open Eczbek opened this issue 1 month ago • 2 comments

https://godbolt.org/z/E899Y1qrq MSVC accepts this

struct S {
	operator int();

	template<typename T> operator T();
};

void f() {
	&S::operator int;
}
<source>:8:2: error: reference to overloaded function could not be resolved; did you mean to call it?
    8 |         &S::operator int;
      |         ^~~~~~~~~~~~~~~~
1 error generated.

Eczbek avatar Oct 09 '26 22:10 Eczbek

@llvm/issue-subscribers-clang-frontend

Author: Eczbek

https://godbolt.org/z/E899Y1qrq MSVC accepts this
struct S {
	operator int();

	template&lt;typename T&gt; operator T();
};

void f() {
	&amp;S::operator int;
}
&lt;source&gt;:8:2: error: reference to overloaded function could not be resolved; did you mean to call it?
    8 |         &amp;S::operator int;
      |         ^~~~~~~~~~~~~~~~
1 error generated.

Not just MSVC, GCC accepts this too.

IvyXu420 avatar Oct 11 '26 03:10 IvyXu420