<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2056: future_errc enums start with value 0 (invalid value for broken_promise)</title>
<meta property="og:title" content="Issue 2056: future_errc enums start with value 0 (invalid value for broken_promise)">
<meta property="og:description" content="C++ library issue. Status: C++14">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2056.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#C++14">C++14</a> status.</em></p>
<h3 id="2056"><a href="lwg-defects.html#2056">2056</a>. <code>future_errc</code> enums start with value 0 (invalid value for <code>broken_promise</code>)</h3>
<p><b>Section:</b> 32.10.1 <a href="https://wg21.link/futures.overview">[futures.overview]</a> <b>Status:</b> <a href="lwg-active.html#C++14">C++14</a>
 <b>Submitter:</b> Nicolai Josuttis <b>Opened:</b> 2011-05-18 <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#futures.overview">issues</a> in [futures.overview].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++14">C++14</a> status.</p>
<p><b>Discussion:</b></p>
<p>
In 32.10.1 <a href="https://wg21.link/futures.overview">[futures.overview]</a> <code>enum class future_errc</code> is defined as follows:
</p><blockquote><pre>
enum class future_errc {
  broken_promise,
  future_already_retrieved,
  promise_already_satisfied,
  no_state
};
</pre></blockquote><p>
With this declaration <code>broken_promise</code> has value 0, which means that
for a <code>future_error f</code> with this code
</p><blockquote><pre>
f.code().operator bool()
</pre></blockquote><p>
yields false, which makes no sense. 0 has to be reserved for "no error".
So, the enums defined here have to start with 1.
<p/>
Howard, Anthony, and Jonathan have no objections.
</p>
<p>[Discussion in Bloomington 2011-08-16]
</p>
<p>
Previous resolution:
</p>
<blockquote class="note">
<p>This wording is relative to the FDIS.</p>
<ol>
<li><p>In 32.10.1 <a href="https://wg21.link/futures.overview">[futures.overview]</a>, header <code>&lt;future&gt;</code> synopsis, fix 
the declaration of <code>future_errc</code> as follows:</p>
<blockquote><pre>
namespace std {
  enum class future_errc {
    <del>broken_promise,</del>
    future_already_retrieved<ins> = 1</ins>,
    promise_already_satisfied,
    no_state<ins>,
    broken_promise</ins>
  };
  [&hellip;]
}
</pre></blockquote>
</li>
</ol>
</blockquote>
<p>
Is this resolution overspecified? These seem to be all implementation-defined. How do users add new values and not conflict with established error codes?
</p><p>
PJP proxy says: over-specified. boo.
</p><p>
Other error codes: look for <code>is_error_code_enum</code> specializations. Only one exists <code>io_errc</code>
</p><p>
Peter: I don't see any other parts of the standard that specify error codes where we have to do something similar.
</p><p>
Suggest that for every place where we add an error code, the following:
</p>
<ol>
   <li> no zero values
   </li><li> all implementation defined values, so future_already_retrieved = implementation_defined
   </li><li> values are distinct
</li></ol>

<p><i>[2012, Kona]</i></p>

<p>
Moved to Tentatively Ready by the post-Kona issues processing subgroup.
</p>

<p><i>[2012, Portland: applied to WP]</i></p>




<p id="res-2056"><b>Proposed resolution:</b></p>
<p>This wording is relative to the FDIS.</p>
<p>In 32.10.1 <a href="https://wg21.link/futures.overview">[futures.overview]</a>, header <code>&lt;future&gt;</code> synopsis, fix 
the declaration of <code>future_errc</code> as follows:</p>

<blockquote><pre>
namespace std {
  enum class future_errc {
    broken_promise<ins> = <var>implementation defined</var></ins>,
    future_already_retrieved<ins> = <var>implementation defined</var></ins>,
    promise_already_satisfied<ins> = <var>implementation defined</var></ins>,
    no_state<ins> = <var>implementation defined</var></ins>
  };
  [&hellip;]
}
</pre></blockquote>
<p>In 32.10.1 <a href="https://wg21.link/futures.overview">[futures.overview]</a>, header <code>&lt;future&gt;</code> synopsis, add a paragraph after paragraph 2 as follows:</p>

<ins>The enum values of <code>future_errc</code> are distinct and not zero.</ins>




</body>
</html>
