<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    Core "tentatively ready" Issues
   </TITLE>
</HEAD>
<BODY>
<TABLE ALIGN="RIGHT" CELLSPACING="0" CELLPADDING="0">
<TR>
<TD ALIGN="RIGHT">
      Document number:
     </TD>
<TD>
       &#160;P2313R0</TD>
</TR>
<TR>
<TD ALIGN="RIGHT">
      Date:
     </TD>
<TD>
      &#160;2021-02-12</TD>
</TR>
<TR>
<TD ALIGN="RIGHT">
      Project:
     </TD>
<TD>
      &#160;Programming Language C++
     </TD>
</TR>
<TR>
<TD ALIGN="RIGHT">
      Reference:
     </TD>
<TD>
      &#160;ISO/IEC IS 14882:2017
     </TD>
</TR>
<TR>
<TD ALIGN="RIGHT">
      Reply to:
     </TD>
<TD>
      &#160;William M. Miller
     </TD>
</TR>
<TR>
<TD></TD>
<TD>
      &#160;Edison Design Group, Inc.
     </TD>
</TR>
<TR>
<TD></TD>
<TD>
      &#160;<A HREF="mailto://wmm@edg.com">wmm@edg.com</A></TD>
</TR>
</TABLE><BR CLEAR="ALL"><BR><CENTER>
<H2>
     Core Language Working Group "tentatively ready" Issues
     for the
     February, 2021 meeting
    </H2>
</CENTER><BR><P>
    References in this document reflect the section and paragraph
    numbering of document
    <A HREF="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/n4868.pdf">WG21 N4868</A>.
   </P>
<HR><A NAME="2470"></A><H4>2470.
  
Multiple array objects providing storage for one object
</H4><B>Section: </B>6.7.2&#160; [intro.object]
 &#160;&#160;&#160;

 <B>Status: </B>tentatively ready
 &#160;&#160;&#160;

 <B>Submitter: </B>Andrey Erokhin
 &#160;&#160;&#160;

 <B>Date: </B>2021-01-29


<P>According to 6.7.2 [intro.object] paragraph 3,</P>

<BLOCKQUOTE>

<P>If a complete object is created
(7.6.2.8 [expr.new]) in storage associated with
another object <I>e</I> of type &#8220;array of <I>N</I>
<TT>unsigned char</TT>&#8221; or of type &#8220;array of <I>N</I>
<TT>std::byte</TT>&#8221; (17.2.1 [cstddef.syn]),
that array <I>provides storage</I> for the created object
if:</P>

<UL><LI><P>the lifetime of <I>e</I> has begun and not ended,
and</P></LI>

<LI><P>the storage for the new object fits entirely
within <I>e</I>, and</P></LI>

<LI><P>there is no smaller array object that satisfies these
constraints.</P></LI>

</UL>

</BLOCKQUOTE>

<P>The intent of the third bullet is to select a unique array
object among those satisfying the first two bullets. However,
it is possible to have multiple array objects of the same
size satisfying the first two bullets. For example:</P>

<PRE>
  unsigned char buffer[8];
  struct OhNo { std::byte data[8]; };
  static_assert(sizeof(OhNo) == 8 &amp;&amp; sizeof(int) == 4);
  OhNo *p = new (buffer) OhNo;   //<SPAN style="font-family:Times;font-style:italic"> </SPAN>buffer<SPAN style="font-family:Times;font-style:italic"> provides storage for </SPAN>OhNo
  int *q = new (p-&gt;data) int;    //<SPAN style="font-family:Times;font-style:italic"> who provides storage for this?</SPAN>
  int *r = new (buffer + 4) int; //<SPAN style="font-family:Times;font-style:italic"> who provides storage for this?</SPAN>
</PRE>

<P><B>Proposed resolution (February, 2021):</B></P>

<P>Change 6.7.2 [intro.object] bullet 3.3 as follows:</P>

<UL><LI><P>there is no <SPAN style="text-decoration:line-through;background-color:#FFA0A0">smaller</SPAN>
array object that satisfies these
constraints <SPAN style="font-weight:bold;background-color:#A0FFA0">nested within <I>e</I></SPAN>.</P></LI>

</UL>

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