<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3342: Library wording uses "initializes x with y", which is underspecified</title>
<meta property="og:title" content="Issue 3342: Library wording uses &quot;initializes x with y&quot;, which is underspecified">
<meta property="og:description" content="C++ library issue. Status: New">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3342.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#New">New</a> status.</em></p>
<h3 id="3342"><a href="lwg-active.html#3342">3342</a>. Library wording uses "initializes <code>x</code> with <code>y</code>", which is underspecified</h3>
<p><b>Section:</b> 22.3.2 <a href="https://wg21.link/pairs.pair">[pairs.pair]</a>, 22.4.4.2 <a href="https://wg21.link/tuple.cnstr">[tuple.cnstr]</a>, 22.6.3.2 <a href="https://wg21.link/variant.ctor">[variant.ctor]</a>, 32.5.8.7.2 <a href="https://wg21.link/util.smartptr.atomic.shared">[util.smartptr.atomic.shared]</a>, 20.6.3 <a href="https://wg21.link/allocator.adaptor.cnstr">[allocator.adaptor.cnstr]</a>, 28.5.6.6 <a href="https://wg21.link/format.parse.ctx">[format.parse.ctx]</a>, 28.5.8.1 <a href="https://wg21.link/format.arg">[format.arg]</a>, 23.6 <a href="https://wg21.link/container.adaptors">[container.adaptors]</a>, 24.5 <a href="https://wg21.link/predef.iterators">[predef.iterators]</a>, 25.5.4.2 <a href="https://wg21.link/range.subrange.ctor">[range.subrange.ctor]</a>, 25.6 <a href="https://wg21.link/range.factories">[range.factories]</a>, 25.7 <a href="https://wg21.link/range.adaptors">[range.adaptors]</a>, 26.10 <a href="https://wg21.link/numeric.ops">[numeric.ops]</a>, 30.9 <a href="https://wg21.link/time.hms">[time.hms]</a>, 28.6.11 <a href="https://wg21.link/re.iter">[re.iter]</a>, 32.5.8 <a href="https://wg21.link/atomics.types.generic">[atomics.types.generic]</a>, 32.5.9 <a href="https://wg21.link/atomics.nonmembers">[atomics.nonmembers]</a>, 32.3 <a href="https://wg21.link/thread.stoptoken">[thread.stoptoken]</a>, 32.4 <a href="https://wg21.link/thread.threads">[thread.threads]</a>, 32.6 <a href="https://wg21.link/thread.mutex">[thread.mutex]</a>, 32.8 <a href="https://wg21.link/thread.sema">[thread.sema]</a>, 32.9 <a href="https://wg21.link/thread.coord">[thread.coord]</a>, 32.10 <a href="https://wg21.link/futures">[futures]</a> <b>Status:</b> <a href="lwg-active.html#New">New</a>
 <b>Submitter:</b> Richard Smith <b>Opened:</b> 2019-11-21 <b>Last modified:</b> 2019-12-08</p>
<p><b>Priority: </b>3
</p>
<p><b>View other</b> <a href="lwg-index-open.html#pairs.pair">active issues</a> in [pairs.pair].</p>
<p><b>View all other</b> <a href="lwg-index.html#pairs.pair">issues</a> in [pairs.pair].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#New">New</a> status.</p>
<p><b>Discussion:</b></p>
<p>
The problem was discussed <a href="https://github.com/cplusplus/draft/pull/3454#discussion_r348198610">here</a>:
</p>
<blockquote style="border-left: 3px solid #ccc;padding-left: 15px;">
<p>
It seems to me that this is just one instance of a systemic problem in the library wording. This phrasing 
"initializes <code>x</code> with <code>y</code>" is common, but underspecified (and formally meaningless) &mdash; 
the library wording either needs to say what kind of initialization is performed, or specify an initializer 
(not an expression) with which to initialize. We should ask LWG to think about this; for each "initializes 
<code>x</code> with <code>y</code>" utterance, the reader should know what kind of initialization we mean.
<p/>
Looking at random through the library wording, the first case I found: 23.6.3.2 <a href="https://wg21.link/queue.cons">[queue.cons]</a>/1:
</p>
<blockquote><p>
<i>Effects:</i> Initializes <code>c</code> with <code>cont</code>.
</p></blockquote>
<p>
The meaning of this depends on whether this is direct- or copy-initialization. (It's obscure, but if <code>T</code> 
is not <i>Cpp17CopyInsertable</i> into the container, it could be the case that one form of initialization 
works and the other does not, or that they both work and do different things.)
<p/>
Another random sample: 26.10.7 <a href="https://wg21.link/partial.sum">[partial.sum]</a>/2:
</p>
<blockquote><p>
<i>Effects:</i> For a non-empty range, the function creates an accumulator <code>acc</code> whose type is 
<code>InputIterator</code>'s value type, initializes it with <code>*first</code>, and assigns the result to <code>*result</code>.
</p></blockquote>
<p>
Again the difference between direct- and copy-initialization is observable here.
<p/>
Perhaps the library should have blanket wording that when it says "initializes", it means by 
direct- or copy-initialization, and that it's unspecified which one you get (or something like that) &mdash; 
and someone should go through all the instances and check if any of them mean something else (I doubt this 
is the only case that does).
</p>
</blockquote>
<p>
Suggestion: either
</p>
<ul>
<li><p>add blanket wording defining what you mean when you say "initializes <code>x</code> with <code>y</code>" 
(e.g., it's unspecified whether copy-initialization or direct-initialization is performed) and make sure 
that that's what's intended for all uses, or</p></li>
<li><p>stop using the "initializes <code>x</code> with <code>y</code>" formulation entirely, and specify the kind 
of initialization on each use, or</p></li>
<li><p>for each such use, ensure that <code>y</code> is an initializer (that is, of the form "<code>= expr</code>" 
or "<code>(expr, expr, &hellip;)</code>" or "<code>= { &hellip; }</code>" or "<code>{ &hellip; }</code>", and not 
merely an expression)</p></li>
</ul>

<p><i>[2019-12-08 Issue Prioritization]</i></p>

<p>Priority to 3 after reflector discussion.</p>


<p id="res-3342"><b>Proposed resolution:</b></p>




</body>
</html>
