[libcxx-commits] [PATCH] D116346: [libc++] Fix bug #52902
Nikolas Klauser via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Sat Jan 1 09:04:11 PST 2022
philnik updated this revision to Diff 396863.
philnik added a comment.
- Added test
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D116346/new/
https://reviews.llvm.org/D116346
Files:
libcxx/include/__iterator/wrap_iter.h
libcxx/test/std/strings/basic.string/string.iterators/iterators.pass.cpp
Index: libcxx/test/std/strings/basic.string/string.iterators/iterators.pass.cpp
===================================================================
--- libcxx/test/std/strings/basic.string/string.iterators/iterators.pass.cpp
+++ libcxx/test/std/strings/basic.string/string.iterators/iterators.pass.cpp
@@ -23,12 +23,13 @@
#include "test_macros.h"
template<class C>
-void test()
+TEST_CONSTEXPR_CXX20 void test()
{
{ // N3644 testing
typename C::iterator ii1{}, ii2{};
typename C::iterator ii4 = ii1;
typename C::const_iterator cii{};
+
assert ( ii1 == ii2 );
assert ( ii1 == ii4 );
@@ -49,10 +50,16 @@
assert (cii - ii1 == 0);
assert (ii1 - cii == 0);
}
+ {
+ C a;
+ typename C::iterator i1 = a.begin();
+ typename C::iterator i2;
+ i2 = i1;
+ assert ( i1 == i2 );
+ }
}
-int main(int, char**)
-{
+TEST_CONSTEXPR_CXX20 bool test() {
test<std::string>();
#ifndef TEST_HAS_NO_WIDE_CHARACTERS
test<std::wstring>();
@@ -65,5 +72,14 @@
test<std::u16string>();
test<std::u32string>();
+ return true;
+}
+
+int main(int, char**)
+{
+ test();
+#if 0
+ static_assert(test());
+#endif
return 0;
}
Index: libcxx/include/__iterator/wrap_iter.h
===================================================================
--- libcxx/include/__iterator/wrap_iter.h
+++ libcxx/include/__iterator/wrap_iter.h
@@ -69,9 +69,10 @@
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_AFTER_CXX11
__wrap_iter& operator=(const __wrap_iter& __x)
{
- if (this != _VSTD::addressof(__x) && !__libcpp_is_constant_evaluated())
+ if (this != _VSTD::addressof(__x))
{
- __get_db()->__iterator_copy(this, _VSTD::addressof(__x));
+ if (!__libcpp_is_constant_evaluated())
+ __get_db()->__iterator_copy(this, _VSTD::addressof(__x));
__i = __x.__i;
}
return *this;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116346.396863.patch
Type: text/x-patch
Size: 1977 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220101/9d1bf18e/attachment.bin>
More information about the libcxx-commits
mailing list