[libcxx-commits] [PATCH] D155399: [libc++] add basic runtime assertions to <semaphore>

Edo via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Jul 17 11:24:03 PDT 2023


diamante0018 added a comment.

You are correct in observing there are four checks, there are three checks because one cannot be tested for. max::() is equivalent to the max value of ptrdiff_t so there is no number that can violate this precondition.
I was asked by @ldionne in a previous review to leave the assertion anyway for an identical situation in D154425 <https://reviews.llvm.org/D154425>.
I will see if I can address your other comments with a diff. Thanks for the review.



================
Comment at: libcxx/include/semaphore:99
+        auto __old = __a_.fetch_add(__update, memory_order_release);
+        _LIBCPP_ASSERT_UNCATEGORIZED(__update <= _LIBCPP_SEMAPHORE_MAX - __old, "update is greater than the expected value");
+
----------------
EricWF wrote:
> Shouldn't this check be using `::max()` rather than the default `_LIBPCP_SEMAPHORE_MAX`?
Unfortunately I don't think I can. ::max() is a definition that is not part of this class and is defined down in this file so it should not be an available definition right here.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D155399/new/

https://reviews.llvm.org/D155399



More information about the libcxx-commits mailing list