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

2022-07-16


2044. decltype(auto) and void

Section: 9.2.9.6  [dcl.spec.auto]     Status: CD4     Submitter: Richard Smith     Date: 2014-11-14

[Adopted at the February, 2016 meeting.]

The resolution of issue 1877 does not correctly handle decltype(auto) return types with void return expressions:

  T f();
  decltype(auto) g() { return f(); }

fails when T is void.

Suggested resolution:

Change 9.2.9.6 [dcl.spec.auto] paragraph 7 as follows:

...In the case of a return with no operand or with an operand of type void, the declared return type shall be auto or decltype(auto) and the deduced return type is void. Otherwise...

Proposed resolution (September, 2015):

Change 9.2.9.6 [dcl.spec.auto] paragraph 7 as follows:

When a variable declared using a placeholder type is initialized, or a return statement occurs in a function declared with a return type that contains a placeholder type, the deduced return type or variable type is determined from the type of its initializer. In the case of a return with no operand or with an operand of type void,:

Otherwise, let T be...