From bce096d34dcf5185b91401a0d4d70a88e7cd1edf Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Mon, 24 Mar 2014 22:25:24 +0000 Subject: [PATCH] Add a test to make sure we're doing the right thing for throwing exceptions from deferred functions. This is LWG issue #2186. No change to the library needed. git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@204678 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../futures/futures.async/async.pass.cpp | 19 +++++++++++++++++++ www/cxx1y_status.html | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/test/thread/futures/futures.async/async.pass.cpp b/test/thread/futures/futures.async/async.pass.cpp index 697eb089..f67abe4f 100644 --- a/test/thread/futures/futures.async/async.pass.cpp +++ b/test/thread/futures/futures.async/async.pass.cpp @@ -55,6 +55,12 @@ std::unique_ptr f4(std::unique_ptr&& p) return std::move(p); } +void f5(int i) +{ + std::this_thread::sleep_for(ms(200)); + throw i; +} + int main() { { @@ -174,4 +180,17 @@ int main() Clock::time_point t1 = Clock::now(); assert(t1-t0 < ms(100)); } + + { + std::future f = std::async(f5, 3); + std::this_thread::sleep_for(ms(300)); + try { f.get(); assert (false); } catch ( int ex ) {} + } + + { + std::future f = std::async(std::launch::deferred, f5, 3); + std::this_thread::sleep_for(ms(300)); + try { f.get(); assert (false); } catch ( int ex ) {} + } + } diff --git a/www/cxx1y_status.html b/www/cxx1y_status.html index 04c3730a..8335a5fb 100644 --- a/www/cxx1y_status.html +++ b/www/cxx1y_status.html @@ -266,7 +266,7 @@ 2359How does regex_constants::nosubs affect basic_regex::mark_count()?IssaquahComplete 2360reverse_iterator::operator*() is unimplementableIssaquahComplete 2104unique_lock move-assignment should not be noexceptIssaquahComplete - 2186Incomplete action on async/launch::deferredIssaquah + 2186Incomplete action on async/launch::deferredIssaquahComplete 2075Progress guarantees, lock-free property, and scheduling assumptionsIssaquah 2288Inconsistent requirements for shared mutexesIssaquahComplete