[libcxx-commits] [PATCH] D101675: [libc++] [LIBCXX-DEBUG-FIXME] Fix an iterator-invalidation issue in string::assign.
Arthur O'Dwyer via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Wed May 5 13:23:54 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdb9425cb060b: [libc++] [LIBCXX-DEBUG-FIXME] Fix an iterator-invalidation issue in string… (authored by arthur.j.odwyer).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D101675/new/
https://reviews.llvm.org/D101675
Files:
libcxx/include/string
libcxx/test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp
Index: libcxx/test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp
===================================================================
--- libcxx/test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp
+++ libcxx/test/std/strings/basic.string/string.modifiers/string_assign/iterator.pass.cpp
@@ -6,8 +6,6 @@
//
//===----------------------------------------------------------------------===//
-// XFAIL: LIBCXX-DEBUG-FIXME
-
// <string>
// template<class InputIterator>
Index: libcxx/include/string
===================================================================
--- libcxx/include/string
+++ libcxx/include/string
@@ -1763,11 +1763,7 @@
template <class _CharT, class _Traits, class _Allocator>
inline
void
-basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type
-#if _LIBCPP_DEBUG_LEVEL == 2
- __pos
-#endif
- )
+basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type __pos)
{
#if _LIBCPP_DEBUG_LEVEL == 2
__c_node* __c = __get_db()->__find_c_and_lock(this);
@@ -1787,6 +1783,8 @@
}
__get_db()->unlock();
}
+#else
+ (void)__pos;
#endif // _LIBCPP_DEBUG_LEVEL == 2
}
@@ -2361,12 +2359,11 @@
size_type __sz = size();
__grow_by(__cap, __n - __cap, __sz, 0, __sz);
}
- else
- __invalidate_iterators_past(__n);
value_type* __p = _VSTD::__to_address(__get_pointer());
traits_type::assign(__p, __n, __c);
traits_type::assign(__p[__n], value_type());
__set_size(__n);
+ __invalidate_iterators_past(__n);
return *this;
}
@@ -2498,13 +2495,12 @@
size_type __sz = size();
__grow_by(__cap, __n - __cap, __sz, 0, __sz);
}
- else
- __invalidate_iterators_past(__n);
pointer __p = __get_pointer();
for (; __first != __last; ++__first, ++__p)
traits_type::assign(*__p, *__first);
traits_type::assign(*__p, value_type());
__set_size(__n);
+ __invalidate_iterators_past(__n);
}
else
{
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101675.343161.patch
Type: text/x-patch
Size: 2248 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210505/56955eab/attachment-0001.bin>
More information about the libcxx-commits
mailing list