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

Edo via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jul 4 13:36:03 PDT 2023


diamante0018 added inline comments.


================
Comment at: libcxx/include/latch:80-81
+    {
+        _LIBCPP_ASSERT_UNCATEGORIZED(__expected >= 0,
+                                     "__expected cannot be negative");
+    }
----------------
diamante0018 wrote:
> ldionne wrote:
> > 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!
> I see, I just saw your comment. I will add the check right away.
I added the check. That should be the last point to address from your previous review. I hope all is good now. Thanks 🐱


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

https://reviews.llvm.org/D154425



More information about the libcxx-commits mailing list