<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 754: Ambiguous return clause for std::uninitialized_copy</title>
<meta property="og:title" content="Issue 754: Ambiguous return clause for std::uninitialized_copy">
<meta property="og:description" content="C++ library issue. Status: NAD Editorial">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue754.html">
<meta property="og:type" content="website">
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
<meta property="og:image:alt" content="C++ logo">
<style>
  p {text-align:justify}
  li {text-align:justify}
  pre code.backtick::before { content: "`" }
  pre code.backtick::after { content: "`" }
  blockquote.note
  {
    background-color:#E0E0E0;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 1px;
    padding-bottom: 1px;
  }
  ins {background-color:#A0FFA0}
  del {background-color:#FFA0A0}
  table.issues-index { border: 1px solid; border-collapse: collapse; }
  table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
  table.issues-index td { padding: 4px; border: 1px solid; }
  table.issues-index td:nth-child(1) { text-align: right; }
  table.issues-index td:nth-child(2) { text-align: left; }
  table.issues-index td:nth-child(3) { text-align: left; }
  table.issues-index td:nth-child(4) { text-align: left; }
  table.issues-index td:nth-child(5) { text-align: center; }
  table.issues-index td:nth-child(6) { text-align: center; }
  table.issues-index td:nth-child(7) { text-align: left; }
  table.issues-index td:nth-child(5) span.no-pr { color: red; }
  @media (prefers-color-scheme: dark) {
     html {
        color: #ddd;
        background-color: black;
     }
     ins {
        background-color: #225522
     }
     del {
        background-color: #662222
     }
     a {
        color: #6af
     }
     a:visited {
        color: #6af
     }
     blockquote.note
     {
        background-color: rgba(255, 255, 255, .10)
     }
  }
</style>
</head>
<body>
<hr>
<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#NAD_Editorial">NAD Editorial</a> status.</em></p>
<h3 id="754"><a href="lwg-closed.html#754">754</a>. Ambiguous return clause for <code>std::uninitialized_copy</code></h3>
<p><b>Section:</b> 26.11.5 <a href="https://wg21.link/uninitialized.copy">[uninitialized.copy]</a> <b>Status:</b> <a href="lwg-active.html#NAD_Editorial">NAD Editorial</a>
 <b>Submitter:</b> Daniel Kr&uuml;gler <b>Opened:</b> 2007-10-15 <b>Last modified:</b> 2016-01-28</p>
<p><b>Priority: </b>Not Prioritized
</p>
<p><b>View all other</b> <a href="lwg-index.html#uninitialized.copy">issues</a> in [uninitialized.copy].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#NAD Editorial">NAD Editorial</a> status.</p>
<p><b>Discussion:</b></p>
<p>
14882-2003, [lib.uninitialized.copy] is currently written as follows:
</p>

<blockquote>
<pre>
template &lt;class InputIterator, class ForwardIterator&gt;
  ForwardIterator uninitialized_copy(InputIterator <i>first</i>, InputIterator <i>last</i>,
                                     ForwardIterator <i>result</i>);
</pre>
<blockquote>
<p>
-1- <i>Effects:</i>
</p>
<blockquote><pre>
for (; first != last; ++result, ++first)
  new (static_cast&lt;void*&gt;(&amp;*result))
    typename iterator_traits&lt;ForwardIterator&gt;::value_type(*first);
</pre></blockquote>
<p>
-2- <i>Returns:</i> <code><i>result</i></code>
</p>
</blockquote>
</blockquote>

<p>
similarily for N2369, and its corresponding section
26.11.5 <a href="https://wg21.link/uninitialized.copy">[uninitialized.copy]</a>.
</p>

<p>
It's not clear to me what the return clause is supposed to mean, I see
two
possible interpretations:
</p>

<ol style="list-style-type:lower-alpha">
<li>
The notion of <code><i>result</i></code> is supposed to mean the value given by the
function parameter <code><i>result</i></code> [Note to the issue editor: Please use italics for
<code><i>result</i></code>].
This seems somewhat implied by recognizing that both the function
parameter
and the name used in the clause do have the same italic font.
</li>
<li>
The notion of "result" is supposed to mean the value of <code><i>result</i></code>
after the
preceding effects clause. This is in fact what all implementations I
checked
do (and which is probably it's intend, because it matches the
specification of <code>std::copy</code>).
</li>
</ol>

<p>
The problem is: I see nothing in the standard which grants that this
interpretation
is correct, specifically [lib.structure.specifications] or
16.3.2.4 <a href="https://wg21.link/structure.specifications">[structure.specifications]</a>
resp. do not clarify which "look-up" rules apply for names found in
the elements
of the detailed specifications - Do they relate to the corresponding
synopsis or
to the effects clause (or possibly other elements)? Fortunately most
detailed
descriptions are unambigious in this regard, e.g. this problem does
not apply
for <code>std::copy</code>.
</p>



<p id="res-754"><b>Proposed resolution:</b></p>
<p>
Change the wording of the return clause to say (26.11.5 <a href="https://wg21.link/uninitialized.copy">[uninitialized.copy]</a>):
</p>

<blockquote>
<p>
-2- <i>Returns:</i> <ins>The value of</ins> <code><i>result</i></code> <ins>after effects have taken place.</ins>
</p>
</blockquote>


<p><i>[
Bellevue:
]</i></p>


<blockquote><p>
Resolution: NAD editorial -- project editor to decide if change is
worthwhile. Concern is that there are many other places this might
occur.
</p></blockquote>




</body>
</html>
