[cfe-dev] libc++: tests of the form wait*.exception.pass.cpp
Eric Fiselier
eric at efcs.ca
Fri Aug 7 09:15:40 PDT 2015
Hi Andrew,
Please see this patch http://reviews.llvm.org/D11046. That patch adds
a more verbose comment that at least explains the point of the test.
It doesn't describe how the expected behavior is achieved. I'll add
that before submitting.
I prefer not to use '#if _LIBCPP_STD_VER` to wrap C++11/C++14 only
tests. Instead I prefer to use LIT's 'REQUIRES', 'UNSUPPORTED' and
'XFAIL' features. This might be inconvenient if you don't use LIT to
run the test suite.
Libc++ also tends to back-port support for things like `wait_for` to
older standard dialects. I wouldn't want libc++ to lose test coverage
of these back-ported extensions. Hopefully we can work towards a
solution that allows non-standard tests to be disabled without libc++
losing coverage.
/Eric
On Fri, Aug 7, 2015 at 5:13 AM, Andrew Parker
<andrew.j.c.parker at gmail.com> wrote:
> 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?
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
More information about the cfe-dev
mailing list