<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 1226: Incomplete changes of #890</title>
<meta property="og:title" content="Issue 1226: Incomplete changes of #890">
<meta property="og:description" content="C++ library issue. Status: Resolved">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue1226.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#Resolved">Resolved</a> status.</em></p>
<h3 id="1226"><a href="lwg-defects.html#1226">1226</a>. Incomplete changes of #890</h3>
<p><b>Section:</b> 32.10.3 <a href="https://wg21.link/futures.errors">[futures.errors]</a> <b>Status:</b> <a href="lwg-active.html#Resolved">Resolved</a>
 <b>Submitter:</b> Daniel Kr&uuml;gler <b>Opened:</b> 2009-10-05 <b>Last modified:</b> 2016-01-28</p>
<p><b>Priority: </b>Not Prioritized
</p>
<p><b>View all issues with</b> <a href="lwg-status.html#Resolved">Resolved</a> status.</p>
<p><b>Discussion:</b></p>
<p>
Defect issue <a href="lwg-defects.html#890" title="Improving &lt;system_error&gt; initialization (Status: C++11)">890</a><sup><a href="https://cplusplus.github.io/LWG/issue890" title="Latest snapshot">(i)</a></sup> overlooked to adapt the <code>future_category</code> from
32.10.1 <a href="https://wg21.link/futures.overview">[futures.overview]</a> and 32.10.3 <a href="https://wg21.link/futures.errors">[futures.errors]</a>:
</p>

<blockquote><pre>
extern const error_category* const future_category;
</pre></blockquote>

<p>
which should be similarly transformed into function form.
</p>

<p><i>[
2009-10-27 Howard:
]</i></p>


<blockquote><p>
Moved to Tentatively Ready after 5 positive votes on c++std-lib.
</p></blockquote>

<p><i>[
2009-11-11 Daniel adds:
]</i></p>


<blockquote>
<p>
I just observe that the proposed resolution of this issue
is incomplete and needs to reworded. The problem is that the
corresponding declarations
</p>

<blockquote><pre>
constexpr error_code make_error_code(future_errc e);
constexpr error_condition make_error_condition(future_errc e);
</pre></blockquote>

<p>
as constexpr functions are incompatible to the requirements of constexpr
functions given their specified implementation. Note that the incompatibility
is <em>not</em> a result of the modifications proposed by the issue resolution,
but already existed within the
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2960.pdf">N2960</a>
state where we have
</p>

<blockquote><pre>
extern const error_category* const future_category;
</pre></blockquote>

<p>
combined with
</p>

<blockquote><pre>
constexpr error_code make_error_code(future_errc e);
</pre>
<blockquote><p>
3 <i>Returns:</i> <code>error_code(static_cast&lt;int&gt;(e), *future_category)</code>.
</p></blockquote>

<pre>
constexpr error_code make_error_condition(future_errc e);
</pre>
<blockquote><p>
4 <i>Returns:</i> <code>error_condition(static_cast&lt;int&gt;(e), *future_category)</code>.
</p></blockquote>
</blockquote>

<p>
Neither is any of the constructors of <code>error_code</code> and <code>error_condition</code>
constexpr, nor does the expression <code>*future_category</code> satisfy the
requirements for a constant expression (7.7 <a href="https://wg21.link/expr.const">[expr.const]</a>/2 bullet 6 in
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n3000.pdf">N3000</a>).
</p>

<p>
The simple solution is just to remove the constexpr qualifiers for both
functions, which makes sense, because none of the remaining <code>make_error_*</code>
overloads in the library is constexpr. One might consider to realize that
those <code>make_*</code> functions could satisfy the constexpr requirements, but this
looks not like an easy task to me, because it would need to rely on a not
yet existing language feature. If such a change is wanted, a new issue
should be opened after the language extension approval (if at all) [1].
</p>

<p>
If no-one complaints I would like to ask Howard to add the following
modifications to this issue, alternatively a new issue could be opened but I
don't know what the best solution is that would cause as little overhead
as possible.
</p>
<p>
What-ever the route is, the following is my proposed resolution for this issue
interaction part of the story:
</p>

<blockquote>
<p>
In 32.10.1 <a href="https://wg21.link/futures.overview">[futures.overview]</a>/1, Header <code>&lt;future&gt;</code> synopsis <em>and</em>
in 32.10.3 <a href="https://wg21.link/futures.errors">[futures.errors]</a>/3+4
change as indicated:
</p>

<blockquote><pre>
<del>constexpr</del> error_code make_error_code(future_errc e);
<del>constexpr</del> error_condition make_error_condition(future_errc e);
</pre></blockquote>
</blockquote>

<p>
[1] Let me add that we have a related  NAD issue here: <a href="lwg-closed.html#832" title="Applying constexpr to System error support (Status: NAD)">832</a><sup><a href="https://cplusplus.github.io/LWG/issue832" title="Latest snapshot">(i)</a></sup>
so the chances for realization are little IMO.
</p>

<p><i>[
Howard: I've updated the proposed wording as Daniel suggests and set to Review.
]</i></p>

</blockquote>

<p><i>[
2009-11-13 Moved to Tentatively Ready after 5 positive votes on c++std-lib.
]</i></p>


<p><i>[
2010 Pittsburgh:
]</i></p>


<blockquote><p>
Moved to <del>NAD Editorial</del><ins>Resolved</ins>.  Rationale added below.
</p></blockquote>



<p><b>Rationale:</b></p>
<p>
Solved by <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3058.html">N3058</a>.
</p>


<p id="res-1226"><b>Proposed resolution:</b></p>
<ol>
<li>
<p>
Change in 32.10.1 <a href="https://wg21.link/futures.overview">[futures.overview]</a>, header <code>&lt;future&gt;</code> synopsis:
</p>

<blockquote><pre>
<del>extern</del> const error_category<ins>&amp;</ins><del>* const</del> future_category<ins>()</ins>;
</pre></blockquote>
</li>

<li>
<p>
In 32.10.1 <a href="https://wg21.link/futures.overview">[futures.overview]</a>/1, Header <code>&lt;future&gt;</code> synopsis 
change as indicated:
</p>

<blockquote><pre>
<del>constexpr</del> error_code make_error_code(future_errc e);
<del>constexpr</del> error_condition make_error_condition(future_errc e);
</pre></blockquote>
</li>

<li>
<p>
Change in 32.10.3 <a href="https://wg21.link/futures.errors">[futures.errors]</a>:
</p>

<blockquote><pre>
<del>extern</del> const error_category<ins>&amp;</ins><del>* const</del> future_category<ins>()</ins>;
</pre>

<blockquote>
<p>
<del>1- <code>future_category</code> shall point to a statically initialized object
of a type derived from class <code>error_category</code>.</del>
</p>
<p>
<ins>1- <i>Returns:</i> A reference to an object of a type
derived from class <code>error_category</code>.</ins>
</p>
</blockquote>

<pre>
<del>constexpr</del> error_code make_error_code(future_errc e);
</pre>

<blockquote><p>
3 <i>Returns:</i> <code>error_code(static_cast&lt;int&gt;(e),
<del>*</del>future_category<ins>()</ins>)</code>.
</p></blockquote>

<pre>
<del>constexpr</del> error_<del>code</del><ins>condition</ins> make_error_condition(future_errc e);
</pre>

<blockquote><p>
4 <i>Returns:</i> <code>error_condition(static_cast&lt;int&gt;(e),
<del>*</del>future_category<ins>()</ins>)</code>.
</p></blockquote>
</blockquote>
</li>
</ol>





</body>
</html>
