[cfe-dev] libc++: tests of the form wait*.exception.pass.cpp

Andrew Parker andrew.j.c.parker at gmail.com
Fri Aug 7 02:13:17 PDT 2015


I've just spent a lot of time trying to figure out why a particular class
of tests were failing for me with MSVC and not with GCC.

For example:

test\std\thread\thread.condition\thread.condition.condvarany\wait_for.exception.pass.cpp

These tests are designed to check that *std::condition_variable::wait_for*
(and friends) will call *std::terminate* when an exception is thrown during
the re-locking of the passed in mutex.

Firstly, I think this is C++14 only, at least according to
http://en.cppreference.com/w/cpp/thread/condition_variable/wait_for.  I
know that's not the single source of truth so please correct me if that's
not the case.  If it is, then I'd like to comment out these tests in a:

#if _LIBCPP_STD_VER > 11
#else
#endif

block.

Secondly, I'd like to add a much more verbose comment as to what these
tests are doing and why, ultimately, they will work.  The latter point is
the more important.  To implement the expected behaviour the tests rely on
the dtr of *std::unique_ptr* calling a nothrow function and the mutex
locking happening from within there (this is why MSVC failed the test as it
doesn't call *std::terminate* if a throw occurs in a nothrow function).

I'll submit a patch (or not) based on comments.

Also, on a side not whilst I remember.  The following functions in
condition_variable.cpp are marked as NOTHROW but actually can throw:

*void*
*condition_variable::wait(unique_lock<mutex>& lk)*

*void*
*condition_variable::__do_timed_wait(unique_lock<mutex>& lk,*
*     chrono::time_point<chrono::system_clock, chrono::nanoseconds> tp)*

Seems like a bug to me!  Is it?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150807/711dafc3/attachment.html>


More information about the cfe-dev mailing list