<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - error code for broken_promise is incorrect & inconsistent with thrown future_error exception"
   href="https://llvm.org/bugs/show_bug.cgi?id=23379">23379</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>error code for broken_promise is incorrect & inconsistent with thrown future_error exception
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libc++
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>vlovich@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu, mclow.lists@gmail.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Broken promises on futures have an error code of 0 which results in the weird
result that std::future_errc::broken_promise isn't comparable to any exception
thrown, contrary to the standard specification & all the examples I've found
online.

Steps:
1. 
// test.cpp
#include <future>
#include <iostream>

int main()
{
    std::future<void> f;
    {
        std::promise<void> p;
        f = p.get_future();
    }

    try {
        f.get();
        std::cerr << "Shouldn't get here?\n";
    } catch(const std::future_error& e) {
       bool is_broken_promise = e.code() ==
std::make_error_condition(std::future_errc::broken_promise);
        std::cout << e.code().message() << "\n";
        std::cout << e.code().value() << "\n";
        std::cout << is_broken_promise << "\n";
    }
}

2. clang++ -std=c++11 -stdlib=libc++ test.cpp && ./a.out
3. clang++ -std=c++14 -stdlib=libc++ test.cpp && ./a.out

Actual for both 2 & 3:
The associated promise has been destructed prior to the associated state
becoming ready.
0
0

Expected for #2:
The associated promise has been destructed prior to the associated state
becoming ready.
0
1

or

The associated promise has been destructed prior to the associated state
becoming ready.
0
1

Expected for #3:
The associated promise has been destructed prior to the associated state
becoming ready.
4
1</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>