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

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jul 4 13:28:18 PDT 2023


ldionne added inline comments.


================
Comment at: libcxx/include/latch:80-81
+    {
+        _LIBCPP_ASSERT_UNCATEGORIZED(__expected >= 0,
+                                     "__expected cannot be negative");
+    }
----------------
diamante0018 wrote:
> ldionne wrote:
> > I think it is also UB if `__expected > max()`, right? If so, let's add an assertion.
> You are right but in this implementation because max is equivalent to std::numeric_limits<ptrdiff_t>::max() it should not be possible
Then the compiler can probably elide the check, but we should still have the check!


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

https://reviews.llvm.org/D154425



More information about the libcxx-commits mailing list