Title
auto as a conversion-type-id
Status
open
Section
9.2.9.6.1 [dcl.spec.auto.general]
Submitter
Jim X

Created on 2021-03-10.00:00:00 last changed 8 months ago

Messages

Date: 2021-03-10.00:00:00

Given the example,

  struct A{
   operator auto(){
     return 0;
   }
  };
  int main(){
    A a;
    a.operator auto(); // #1
    a.operator int();  // #2
  }

there is implementation divergence regarding which, if either, of the calls is well-formed. MSVC and clang reject #2, g++ rejects #1, and EDG rejects both.

According to 9.2.9.6.1 [dcl.spec.auto.general] paragraph 6:

A program that uses a placeholder type in a context not explicitly allowed in 9.2.9.6 [dcl.spec.auto] is ill-formed.

The use of auto as a conversion-type-id in a function call is not mentioned in that section; however, the section is dealing with declarative contexts rather than expressions, so it's not clear how much weight that observation should carry.

History
Date User Action Args
2021-03-10 00:00:00admincreate