From 2cbc263ced1e2e8151fd8096e1f4e8b87eaeaa28 Mon Sep 17 00:00:00 2001 From: Dmitry Arkhipov Date: Sun, 28 Aug 2022 13:35:03 +0300 Subject: [PATCH] array self-swap --- include/boost/json/impl/array.ipp | 1 - test/array.cpp | 6 ++++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/boost/json/impl/array.ipp b/include/boost/json/impl/array.ipp index cbd06e4b..5cd68bd1 100644 --- a/include/boost/json/impl/array.ipp +++ b/include/boost/json/impl/array.ipp @@ -593,7 +593,6 @@ void array:: swap(array& other) { - BOOST_ASSERT(this != &other); if(*sp_ == *other.sp_) { t_ = detail::exchange( diff --git a/test/array.cpp b/test/array.cpp index ace871bf..0c06f961 100644 --- a/test/array.cpp +++ b/test/array.cpp @@ -1154,6 +1154,12 @@ public: check(a1); BOOST_TEST(a2.size() == 1); }); + fail_loop([&](storage_ptr const& sp) + { + array a({1, true, str_}, sp); + swap(a, a); + check(a); + }); } }