This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 115e. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2024-11-11


2493. auto as a conversion-type-id

Section: 9.2.9.7.1  [dcl.spec.auto.general]     Status: dup     Submitter: Jim X     Date: 2021-03-10

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.7.1 [dcl.spec.auto.general] paragraph 6:

A program that uses a placeholder type in a context not explicitly allowed in 9.2.9.7 [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.

Rationale (December, 2021):

This issue is a duplicate of issue 1670.