Skip to content

[dcl.spec.auto.general] Call to conversion function whose conversion-function-id contains a placeholder CWG2493 #4811

Open
@xmh0511

Description

@xmh0511
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cwgIssue must be reviewed by CWG.not-editorialIssue is not deemed editorial; the editorial issue is kept open for tracking.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions