Consider this example:
struct A{
template<class T>
operator T(); // #1
};
struct B:A{
template<class U>
operator U&&(); // #2
};
int main(){
B b;
int a = b; // #3
b.operator int(); // #4
}
According to [class.member.lookup] p7
If N is a non-dependent conversion-function-id, conversion function templates that are members of T are considered. For each such template F, the lookup set
S(t,T)is constructed, considering a function template declaration to have the nametonly if it corresponds to a declaration of F ([basic.scope.scope]). The members of the declaration set of each such lookup set, which shall not be an invalid set, are included in the result.
#1 and #2 are both included in the lookup result regardless of what the conversion-function-ids are in #3 and #4. The diagnosis for #3 is what we expect, in other words, both #1 and #2 are candidates and they are indistinguishable.
However, it seems that implementations only consider #2 as the unique candidate when processing #4. As said above, the candidate set should be the same for either #3 or #4. Do I omit some other rules that cause the difference? Or, Is it a bug in implementations?