cplusplus / cplusplus/draft

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

Open
#4,811 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

cwg not-editorial
Dominant language
TeX
Stars
221
Forks
813
Avg merge
16h 4m
Merged PRs (30d)
36

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading [dcl.spec.auto#6] and [dcl.spec.auto#13] in the C++ draft, then compare the GCC and Clang behavior described for the two calls. Determine how the standard names and permits a conversion function whose conversion-function-id contains a placeholder; done means the wording resolves the ambiguity between the two forms.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.