Title
void in an empty parameter list
Status
cd3
Section
11.3.5 [dcl.fct]
Submitter
Ben Hutchings

Created on 2006-04-22.00:00:00, last changed 2014-03-03.00:00:00.

Messages

Date: 2012-02-15.00:00:00

[Voted into the WP at the February, 2012 meeting; moved to DR at the October, 2012 meeting.]

Date: 2011-08-15.00:00:00

Proposed resolution (August, 2011):

Change 11.3.5 [dcl.fct] paragraph 4 as follows:

...If the parameter-declaration-clause is empty, the function takes no arguments. The parameter list (void) A parameter list consisting of a single unnamed parameter of non-dependent type void is equivalent to the an empty parameter list. Except for this special case, a parameter shall not have type cv void shall not be a parameter type (though types derived from void, such as void*, can). If the parameter-declaration-clause terminates...

This resolution also resolves issue 332.

Date: 2006-10-15.00:00:00

Notes from the October, 2006 meeting:

The CWG did not take a formal position on this issue; however, there was some concern expressed over the treatment of function templates and member functions of class templates if the C++ rule were changed: for a template parameter T, would a function taking a single parameter of type T become a no-parameter function if it were instantiated with T = void?

Date: 2006-04-22.00:00:00

11.3.5 [dcl.fct] paragraph 2 says,

The parameter list (void) is equivalent to the empty parameter list.

This special case is intended for C compatibility, but C99 describes it differently (6.7.5.3 paragraph 10):

The special case of an unnamed parameter of type void as the only item in the list specifies that the function has no parameters.

The C99 formulation allows typedefs for void, while C++ (and C90) accept only the keyword itself in this role. Should the C99 approach be adopted?

History
Date User Action Args
2014-03-03 00:00:00adminsetstatus: drwp -> cd3
2012-11-03 00:00:00adminsetstatus: dr -> drwp
2012-02-27 00:00:00adminsetmessages: + msg3810
2012-02-27 00:00:00adminsetstatus: ready -> dr
2011-09-06 00:00:00adminsetmessages: + msg3461
2011-09-06 00:00:00adminsetstatus: open -> ready
2006-11-05 00:00:00adminsetmessages: + msg1421
2006-04-22 00:00:00admincreate