<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 577</TITLE>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<STYLE TYPE="text/css">
  INS { text-decoration:none; font-weight:bold; background-color:#A0FFA0 }
  .INS { text-decoration:none; background-color:#D0FFD0 }
  DEL { text-decoration:line-through; background-color:#FFA0A0 }
  .DEL { text-decoration:line-through; background-color: #FFD0D0 }
  @media (prefers-color-scheme: dark) {
    HTML { background-color:#202020; color:#f0f0f0; }
    A { color:#5bc0ff; }
    A:visited { color:#c6a8ff; }
    A:hover, a:focus { color:#afd7ff; }
    INS { background-color:#033a16; color:#aff5b4; }
    .INS { background-color: #033a16; }
    DEL { background-color:#67060c; color:#ffdcd7; }
    .DEL { background-color:#67060c; }
  }
  SPAN.cmnt { font-family:Times; font-style:italic }
</STYLE>
</HEAD>
<BODY>
<P><EM>This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21
  Core Issues List revision 118b.
  See http://www.open-std.org/jtc1/sc22/wg21/ for the official
  list.</EM></P>
<P>2025-09-28</P>
<HR>
<A NAME="577"></A><H4>577.
  
<TT>void</TT> in an empty parameter list
</H4>
<B>Section: </B>9.3.4.6&#160; [<A href="https://wg21.link/dcl.fct">dcl.fct</A>]
 &#160;&#160;&#160;

 <B>Status: </B>CD3
 &#160;&#160;&#160;

 <B>Submitter: </B>Ben Hutchings
 &#160;&#160;&#160;

 <B>Date: </B>22 April 2006<BR>


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

<P>9.3.4.6 [<A href="https://wg21.link/dcl.fct#2">dcl.fct</A>] paragraph 2 says,</P>

<BLOCKQUOTE>

The parameter list <TT>(void)</TT> is equivalent to the empty
parameter list.

</BLOCKQUOTE>

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

<BLOCKQUOTE>

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

</BLOCKQUOTE>

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

<P><B>Notes from the October, 2006 meeting:</B></P>

<P>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 <TT>T</TT>, would a function
taking a single parameter of type <TT>T</TT> become a no-parameter
function if it were instantiated with <TT>T = void</TT>?</P>

<P><B>Proposed resolution (August, 2011):</B></P>

<P>Change 9.3.4.6 [<A href="https://wg21.link/dcl.fct#4">dcl.fct</A>] paragraph 4 as follows:</P>

<BLOCKQUOTE>

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

</BLOCKQUOTE>

<P>This resolution also resolves <A HREF="332.html">issue 332</A>.</P>

<BR><BR>
</BODY>
</HTML>
