Description
struct A{
operator auto(){
return 0;
}
};
int main(){
A a;
a.operator auto(); // #1
a.operator int(); // #2
}
In this example, GCC only accepts the manner of #2 while Clang only accepts #1. However, The usage of #1 seems to be ill-formed as per [dcl.spec.auto#6]. For operator int
, it's not the id-expression of the conversion function whose name should have been operator auto
.
As per [dcl.spec.auto#13], that is:
Redeclarations or specializations of a function or function template with a declared return type that uses a placeholder type shall also use that placeholder, not a deduced type.
So, it seems that operator auto
might be the unique name to nominate the conversion function(As a qualified-id that appears in the declarator-id when defining the entity outside the enclosing class definition).
So, the issue falls out which is the name of the conversion function? Literally, the unique name should be operator auto
, however, when using the name as an id-expression of a class member access expression, such usage is forbidden by [dcl.spec.auto]. The standard does not specify what should do here.