https://llvm.org/bugs/show_bug.cgi?id=23379
Bug ID: 23379
Summary: error code for broken_promise is incorrect &
inconsistent with thrown future_error exception
Product: libc++
Version: unspecified
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected], [email protected]
Classification: Unclassified
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
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs