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

2022-08-19


2351. void{}

Section: 7.6.1.4  [expr.type.conv]     Status: CD5     Submitter: Peter Dimov     Date: 2017-06-26

[Accepted as a DR at the June, 2018 (Rapperswil) meeting.]

According to 7.6.1.4 [expr.type.conv] paragraph 2,

If the initializer is a parenthesized single expression, the type conversion expression is equivalent to the corresponding cast expression (7.6.3 [expr.cast]). Otherwise, if the type is cv void and the initializer is () , the expression is a prvalue of the specified type that performs no initialization. Otherwise, the expression is a prvalue of the specified type whose result object is direct-initialized (9.4 [dcl.init]) with the initializer. For an expression of the form T(), T shall not be an array type.

It seems an oversight that void{} is not treated like void().

Proposed resolution, April, 2018:

Change 7.6.1.4 [expr.type.conv] paragraph 2 as follows:

...Otherwise, if the type is cv void and the initializer is () or {}, the expression is a prvalue of the specified type that performs no initialization. Otherwise...