[libcxx-commits] [PATCH] D101674: [libc++] [LIBCXX-DEBUG-FIXME] Constexpr char_traits::copy mustn't compare unrelated pointers.

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Sep 16 10:01:26 PDT 2021


Quuxplusone added inline comments.


================
Comment at: libcxx/include/__string:268
 {
-    _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
+    if (!__libcpp_is_constant_evaluated()) {
+        _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range");
----------------
Mordante wrote:
> WDYT about adding a short comment. `// comparing unrelated pointers is invalid in a constexpr function`?
Seems relatively harmless, but repetitive (do it in all 6 places, right?). And if anyone did wonder enough about why the `if` was there, they could always remove it and see what tests broke. So, I'm ambivalent, but can add the comment if someone else — @ldionne? — also thinks it's a good idea.
Nit: `s/constexpr function/constant expression/` or maybe `constexpr context` (which is a phrase I use a lot but has no textual support in the standard AFAIK).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101674



More information about the libcxx-commits mailing list