<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<TITLE>
    CWG Issue 1338</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="1338"></A><H4>1338.
  
Aliasing and allocation functions
</H4>
<B>Section: </B>6.8.6.5.2&#160; [<A href="https://wg21.link/basic.stc.dynamic.allocation">basic.stc.dynamic.allocation</A>]
 &#160;&#160;&#160;

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

 <B>Submitter: </B>Jason Merrill
 &#160;&#160;&#160;

 <B>Date: </B>2011-08-03<BR>


<P>[Moved to DR at the November, 2014 meeting.]</P>



<P>In 6.8.6.5.2 [<A href="https://wg21.link/basic.stc.dynamic.allocation#2">basic.stc.dynamic.allocation</A>] paragraph 2, allocation functions
are constrained to return a pointer that is different from any previously
returned pointer that has not been passed to a deallocation function.
This does not, for instance, prohibit returning a pointer to storage that
is part of another object, for example, a pool of storage.  The potential
implications of this for aliasing should be spelled out.</P>

<P>(See also issues <A HREF="1027.html">1027</A> and
<A HREF="1116.html">1116</A>.)</P>

<P><B>Additional note (March, 2013):</B></P>

<P>One possibility to allow reasonable optimizations would be to require
that allocation packages hide their storage in file-static variables,
perhaps by adding wording such as:</P>

<BLOCKQUOTE>

Furthermore, <TT>p0</TT> shall point to an object distinct from any other
object that is accessible outside the implementation of the allocation and
deallocation functions.

</BLOCKQUOTE>



<P><B>Additional note, April, 2013:</B></P>

<P>Concern was expressed that a pool class might provide an
interface for iterating over all the pointers that were given out
from the pool, and this usage should be supported.
</P>

<P><B>Notes from the September, 2013 meeting:</B></P>

<P>CWG agreed that changes for this issue should apply only to
non-placement forms.</P>

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

<P>Change 6.8.6.5.2 [<A href="https://wg21.link/basic.stc.dynamic.allocation#2">basic.stc.dynamic.allocation</A>] paragraph 2 as follows:</P>

<BLOCKQUOTE>

...If the request succeeds, the value returned shall be a non-null pointer
value (7.3.12 [<A href="https://wg21.link/conv.ptr">conv.ptr</A>]) <TT>p0</TT> different from any previously
returned value <TT>p1</TT>, unless that value <TT>p1</TT> was subsequently
passed to an <TT>operator delete</TT>. <INS>Furthermore, for the library
allocation functions in 17.6.3.2 [<A href="https://wg21.link/new.delete.single">new.delete.single</A>] and
17.6.3.3 [<A href="https://wg21.link/new.delete.array">new.delete.array</A>], <TT>p0</TT> shall point to a block of
storage disjoint from the storage for any other object accessible to the
caller.</INS> The effect of indirecting through a pointer returned as a
request for zero size is undefined.<SUP>36</SUP>

</BLOCKQUOTE>

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