<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 328</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="328"></A><H4>328.
  
Missing requirement that class member types be complete
</H4>
<B>Section: </B>11.4&#160; [<A href="https://wg21.link/class.mem">class.mem</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Michiel Salters
 &#160;&#160;&#160;

 <B>Date: </B>10 Dec 2001<BR>


<P>[Voted into WP at March 2004 meeting.]</P>

<P>Is it legal to use an incomplete type (6.9 [<A href="https://wg21.link/basic.types#6">basic.types</A>] paragraph 6)
 as a
class member, if no object of such class is ever created ?</P>

<P>And as a class template member, even if the template is instantiated,
but no object of the instantiated class is created?</P>

<P>The consensus seems to be NO, but no wording was found in the standard
which explicitly disallows it.</P>

<P>The problem seems to be that most of the restrictions on incomplete types
are on their use in objects, but class members are not objects.</P>

<P>A possible resolution, if this is considered a defect, is to add to
6.3 [<A href="https://wg21.link/basic.def.odr#4">basic.def.odr</A>] paragraph 4, (situations when T must be complete),
the use of T as a member of a class or instantiated class template.</P>

<P>The thread on comp.std.c++ which brought up the issue was
"Compiler differences: which is correct?", started 2001 11 30.
&lt;3c07c8fb$0$8507$ed9e5944@reading.news.pipex.net&gt;</P>

<P><B>Proposed Resolution (April 2002, revised April 2003):</B></P>

<P>Change the first bullet of the note in 6.3 [<A href="https://wg21.link/basic.def.odr#4">basic.def.odr</A>] paragraph 4
and add two new bullets following it, as follows:</P>
<UL>
<LI>an object of type <TT>T</TT> is defined
(6.2 [<A href="https://wg21.link/basic.def">basic.def</A>]<DEL>, 7.6.2.8 [<A href="https://wg21.link/expr.new">expr.new</A>]</DEL>), or</LI>
<LI>a non-static class data member of type <TT>T</TT> is declared
(11.4 [<A href="https://wg21.link/class.mem">class.mem</A>]), or</LI>
<LI>
<TT>T</TT> is used as the object type or array element type
in a <I>new-expression</I> (7.6.2.8 [<A href="https://wg21.link/expr.new">expr.new</A>]), or</LI>
</UL>

<P>
Replace 11.4 [<A href="https://wg21.link/class.mem#8">class.mem</A>] paragraph 8 by:</P>
<BLOCKQUOTE>
Non-<TT>static</TT> (11.4.9 [<A href="https://wg21.link/class.static">class.static</A>]) data members shall
not have incomplete types.
In particular, a class <TT>C</TT> shall not contain a non-<TT>static</TT>
member of class <TT>C</TT>, but it can contain a pointer or reference to
an object of class <TT>C</TT>.
</BLOCKQUOTE>

<P>See also 6.9 [<A href="https://wg21.link/basic.types#6">basic.types</A>] paragraph 6, which is relevant
but not changed by the Proposed Resolution.</P>

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