<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 716</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="716"></A><H4>716.
  
Specifications that should apply only to non-static union data members
</H4>
<B>Section: </B>11.5&#160; [<A href="https://wg21.link/class.union">class.union</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Mike Miller
 &#160;&#160;&#160;

 <B>Date: </B>17 September, 2008<BR>


<P>[Voted into WP at July, 2009 meeting.]</P>

<P>Unions are no longer forbidden to have static data members; however,
much of the wording of 11.5 [<A href="https://wg21.link/class.union">class.union</A>] (and possibly other
places in the Standard) is still written with that assumption and
refers only to &#8220;data members&#8221; when clearly non-static
data members are in view.  From paragraph 1, for example:</P>

<BLOCKQUOTE>

In a union, at most one of the <B>data members</B> can be active
at any time... The size of a union is sufficient
to contain the largest of its <B>data members</B>...

</BLOCKQUOTE>

<P><B>Proposed resolution (March, 2009):</B></P>

<OL>
<LI><P>Change the footnote in 6.9.5 [<A href="https://wg21.link/basic.type.qualifier#1">basic.type.qualifier</A>] paragraph 1
as follows:</P></LI>

<BLOCKQUOTE>

The same representation and alignment requirements are meant to imply
interchangeability as arguments to functions, return values from
functions, and <INS>non-static data</INS> members of unions.

</BLOCKQUOTE>

<LI><P>Change 7.2.1 [<A href="https://wg21.link/basic.lval#15.6">basic.lval</A>] bullet 15.6 as
follows:</P></LI>

<UL><LI>an aggregate or union type that includes one of the
aforementioned types among its <INS>elements or non-static data</INS>
members (including, recursively, <DEL>a</DEL> <INS>an element or non-static
data</INS> member of a subaggregate or contained union),</LI></UL>

<LI><P>Change 7.6.9 [<A href="https://wg21.link/expr.rel#2.5">expr.rel</A>] bullet 2.5 as
follows:</P></LI>

<UL><LI>If two pointers point to <INS>non-static</INS> data members of the
same union object, they compare equal (after conversion to
<TT>void*</TT>, if necessary)...</LI></UL>

<LI><P>Change 9.13.2 [<A href="https://wg21.link/dcl.align#8">dcl.align</A>] paragraph 8 as follows:</P></LI>

<BLOCKQUOTE>

[<I>Note:</I> the alignment of a union type can be strengthened by
applying the alignment attribute to any <INS>non-static data</INS> member
of the union.  &#8212;<I>end note</I>]

</BLOCKQUOTE>

<LI><P>Change 9.5.2 [<A href="https://wg21.link/dcl.init.aggr#15">dcl.init.aggr</A>] paragraph 15 as follows:</P></LI>

<BLOCKQUOTE>

When a union is initialized with a brace-enclosed initializer, the
braces shall only contain an <I>initializer-clause</I> for the
first <INS>non-static data</INS> member of the union...

</BLOCKQUOTE>

<LI><P>Change 11.5 [<A href="https://wg21.link/class.union#1">class.union</A>] paragraph 1 as follows:</P></LI>

<BLOCKQUOTE>

In a union, at most one of the <INS>non-static</INS> data members can be
active at any time, that is, the value of at most one of the
<INS>non-static</INS> data members can be stored in a union at any time.
[<I>Note:</I> one special guarantee is made in order to simplify the
use of unions: If a standard-layout union contains several
standard-layout structs that share a common initial sequence
(11.4 [<A href="https://wg21.link/class.mem">class.mem</A>]), and if an object of this standard-layout
union type contains one of the standard-layout structs, it is
permitted to inspect the common initial sequence of any of
standard-layout struct members; see 11.4 [<A href="https://wg21.link/class.mem">class.mem</A>]. &#8212;<I>end note</I>] The size of a union is sufficient
to contain the largest of its <INS>non-static</INS> data members.  Each
<INS>non-static</INS> data member is allocated as if it were the sole
member of a struct.  A union can have...

</BLOCKQUOTE>

</OL>

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