[libcxx-commits] [PATCH] D98573: [libc++] Remove most of the special logic for "noexcept iterators" in basic_string

Arthur O'Dwyer via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Fri Apr 16 06:49:18 PDT 2021


Quuxplusone added inline comments.


================
Comment at: libcxx/include/string:2670
+        if (__needs_grow && (!__libcpp_is_trivial_iterator<_ForwardIterator>::value ||
+                             _VSTD::__ptr_in_range(_VSTD::addressof(__tmp_ref), data(), data() + size())))
         {
----------------
It occurred to me just now (and I've asked in #standardese on Slack) that this condition is insufficient to deal with the trailing null byte, which is accessible but not part of the range `[data, data+size)`. Here are two problematic cases in the wild today:
https://godbolt.org/z/q6dnKEvqc (libstdc++ seems to fail but only on Clang, somehow)
https://godbolt.org/z/da7zq58c6 (libc++ fails)
If these cases are legitimate, then I might need to continue messing with this code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98573



More information about the libcxx-commits mailing list