[libcxx-commits] [PATCH] D154425: [libc++] add basic runtime assertions to <latch>
Louis Dionne via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Jul 5 05:51:18 PDT 2023
ldionne added inline comments.
================
Comment at: libcxx/include/latch:117-118
{
+ _LIBCPP_ASSERT_UNCATEGORIZED(
+ __update >= 0, "latch::arrive_and_wait called with a negative value");
+
----------------
To avoid being inconsistent, I think I would remove this assertion and add a comment saying `// preconditions on __update are checked in count_down()`.
================
Comment at: libcxx/test/libcxx/thread/thread.latch/assert.ctor.pass.cpp:33
+int main(int, char **) {
+ { check_latch_invalid(-1); }
+
----------------
You should do this instead:
```
TEST_LIBCPP_ASSERT_FAILURE([]{ std::latch foo(-1); }(), "assertion message");
// and add a comment that we can't check the precondition for max() because there's no value that would violate the precondition (in our implementation)
```
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D154425/new/
https://reviews.llvm.org/D154425
More information about the libcxx-commits
mailing list