<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 2475</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="2475"></A><H4>2475.
  
Object declarations of type <I>cv</I> <TT>void</TT>
</H4>
<B>Section: </B>6.9.2&#160; [<A href="https://wg21.link/basic.fundamental">basic.fundamental</A>]
 &#160;&#160;&#160;

 <B>Status: </B>C++23
 &#160;&#160;&#160;

 <B>Submitter: </B>Krystian Stasiowski
 &#160;&#160;&#160;

 <B>Date: </B>2020-04-22
  &#160;&#160;&#160;
  <B>Liaison: </B>WG14<BR>


<P>[Accepted as a DR at the February, 2023 meeting.]</P>

<P>(From editorial issue
<A HREF="https://github.com/cplusplus/draft/issues/3953">3953</A>.)
</P>

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

<P><B>Notes from the December, 2020 teleconference:</B></P>

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

<P><B>CWG 2022-11-11</B></P>

<P>CWG resolved to making such declarations ill-formed.</P>

<P><B>Proposed resolution (approved by CWG 2022-12-02; amended 2023-02-06):</B></P>

<P>Change in 9.1 [<A href="https://wg21.link/dcl.pre#7">dcl.pre</A>] paragraph 7 as follows:</P>

<BLOCKQUOTE>

If the <I>decl-specifier-seq</I> contains the <TT>typedef</TT>
specifier, the declaration is <DEL>called</DEL> a <I>typedef declaration</I> and
each <I>declarator-id</I> is declared to be a <I>typedef-name</I>,
synonymous with its associated type (9.2.4 [<A href="https://wg21.link/dcl.typedef">dcl.typedef</A>]).
[ <I>Note 4</I>: Such a <I>declarator-id</I> is an
identifier (11.4.8.3 [<A href="https://wg21.link/class.conv.fct">class.conv.fct</A>]). &#8212;<I>end note</I>]
<DEL>If the <I>decl-specifier-seq</I> contains no typedef specifier,</DEL>
<INS>Otherwise, if the type associated
with a <I>declarator-id</I> is a function type
(9.3.4.6 [<A href="https://wg21.link/dcl.fct">dcl.fct</A>]),</INS>
the declaration is <DEL>called</DEL> a <I>function declaration</I>
<DEL>if the type associated with a <I>declarator-id</I> is a function type
(9.3.4.6 [<A href="https://wg21.link/dcl.fct">dcl.fct</A>]) and</DEL>
<INS>. Otherwise, if the type associated with a <I>declarator-id</I>
is an object or reference type, the declaration is</INS> an <I>object declaration</I>
<DEL>otherwise</DEL>.
<INS>Otherwise, the program is ill-formed.</INS>

<P class="ins">
[ Example:
</P>

<PRE class="ins">
int f(), x;            //<SPAN CLASS="cmnt"> OK, function declaration for </SPAN>f<SPAN CLASS="cmnt"> and object declaration for </SPAN>x
extern void g(),       //<SPAN CLASS="cmnt"> OK, function declaration for </SPAN>g
  y;                   //<SPAN CLASS="cmnt"> error: </SPAN>void<SPAN CLASS="cmnt"> is not an object type</SPAN>
</PRE>
<P class="ins">
-- end example ]
</P>

</BLOCKQUOTE>

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