Object declarations of type cv void
6.8.2 [basic.fundamental]
Krystian Stasiowski

Created on 2020-04-22.00:00:00 last changed 2 months ago


Date: 2023-02-06.21:43:56

Proposed resolution (approved by CWG 2022-12-02; amended 2023-02-06):

Change in 9.1 [dcl.pre] paragraph 7 as follows:

If the decl-specifier-seq contains the typedef specifier, the declaration is called a typedef declaration and each declarator-id is declared to be a typedef-name, synonymous with its associated type (9.2.4 [dcl.typedef]). [ Note 4: Such a declarator-id is an identifier ( [class.conv.fct]). —end note] If the decl-specifier-seq contains no typedef specifier, Otherwise, if the type associated with a declarator-id is a function type ( [dcl.fct]), the declaration is called a function declaration if the type associated with a declarator-id is a function type ( [dcl.fct]) and . Otherwise, if the type associated with a declarator-id is an object or reference type, the declaration is an object declaration otherwise. Otherwise, the program is ill-formed.

[ Example:

int f(), x;            // OK, function declaration for f and object declaration for x
extern void g(),       // OK, function declaration for g
  y;                   // error: void is not an object type

-- end example ]

Date: 2022-12-02.23:21:56

CWG 2022-11-11

CWG resolved to making such declarations ill-formed.

Date: 2020-12-15.00:00:00

Notes from the December, 2020 teleconference:

Such declarations are permitted in C, so this question was referred to the C liaison for investigation.

Date: 2023-02-15.00:00:00

[Accepted as a DR at the February, 2023 meeting.]

(From editorial issue 3953.)

Although an object cannot be defined with a type of cv void, there is nothing preventing a non-defining declaration of an object with that type. Should it be disallowed?

Date User Action Args
2023-07-16 13:00:43adminsetstatus: open -> c++23
2023-07-16 13:00:43adminsetstatus: dr -> open
2023-02-18 18:43:04adminsetstatus: ready -> dr
2023-02-06 21:43:56adminsetstatus: tentatively ready -> ready
2022-12-02 23:21:56adminsetmessages: + msg7074
2022-12-02 23:21:56adminsetstatus: drafting -> tentatively ready
2022-11-20 07:54:16adminsetmessages: + msg7041
2022-11-20 07:54:16adminsetstatus: review -> drafting
2022-11-11 09:36:07adminsetstatus: open -> review
2021-02-17 00:00:00adminsetmessages: + msg6493
2020-04-22 00:00:00admincreate