diff --git a/include/etl/multimap.h b/include/etl/multimap.h index 832e0c78..4f33ba4e 100644 --- a/include/etl/multimap.h +++ b/include/etl/multimap.h @@ -593,6 +593,11 @@ namespace etl // otherwise we might lose the other child of the swap node replacement = swap->children[1 - swap->dir]; + if (replacement != nullptr) + { + replacement->parent = swap->parent; + } + // Point swap node to detached node's parent, children and weight swap->parent = detached->parent; swap->children[(uint_least8_t) kLeft] = detached->children[(uint_least8_t) kLeft]; diff --git a/include/etl/multiset.h b/include/etl/multiset.h index 0c09c74e..60e55c2a 100644 --- a/include/etl/multiset.h +++ b/include/etl/multiset.h @@ -276,6 +276,11 @@ namespace etl // otherwise we might lose the other child of the swap node replacement = swap->children[1 - swap->dir]; + if (replacement != nullptr) + { + replacement->parent = swap->parent; + } + // Point swap node to detached node's parent, children and weight swap->parent = detached->parent; swap->children[kLeft] = detached->children[kLeft]; diff --git a/include/etl/version.h b/include/etl/version.h index b90b1f9a..5e4bc5e4 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -39,7 +39,7 @@ SOFTWARE. #define ETL_VERSION_MAJOR 14 #define ETL_VERSION_MINOR 35 -#define ETL_VERSION_PATCH 4 +#define ETL_VERSION_PATCH 5 #define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) "." ETL_STRINGIFY(ETL_VERSION_MINOR) "." ETL_STRINGIFY(ETL_VERSION_PATCH) #define ETL_VERSION_W ETL_STRINGIFY(ETL_VERSION_MAJOR) L"." ETL_STRINGIFY(ETL_VERSION_MINOR) L"." ETL_STRINGIFY(ETL_VERSION_PATCH) diff --git a/library.json b/library.json index 2074978d..0dacced1 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "Embedded Template Library", - "version": "14.35.4", + "version": "14.35.5", "authors": { "name": "John Wellbelove", "email": "" diff --git a/library.properties b/library.properties index 6bb34937..b01b4c49 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=Embedded Template Library -version=14.35.4 +version=14.35.5 author= John Wellbelove maintainer=John Wellbelove license=MIT diff --git a/support/Release notes.txt b/support/Release notes.txt index feab4143..01ec4948 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,7 @@ +=============================================================================== +14.35.5 +Bug fix for etl::multiset & etl::multimap erase. + =============================================================================== 14.35.4 Bug fix for etl::set & etl::map lower_bound. diff --git a/test/test_multimap.cpp b/test/test_multimap.cpp index 328039ee..2abe9ff6 100755 --- a/test/test_multimap.cpp +++ b/test/test_multimap.cpp @@ -1144,5 +1144,40 @@ namespace } } } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_erase_bug) + { + using Data = etl::multimap; + + int keys[10] = { 3, 2, 1, 0, 3, 0, 3, 0, 2, 2 }; + + Data data; + + for (int eltNum = 0; eltNum != 10; ++eltNum) + { + data.insert(Data::value_type(keys[eltNum], eltNum)); + } + + data.erase(2); + + int prv = INT_MAX; + Data::const_reverse_iterator pos; + + bool pass = true; + + for (pos = data.crbegin(); pos != data.crend(); ++pos) + { + if (pos->first > prv) + { + pass = false; + break; + } + + prv = pos->first; + } + + CHECK(pass); + } }; } diff --git a/test/test_multiset.cpp b/test/test_multiset.cpp index da8721ba..9ebbc7d7 100755 --- a/test/test_multiset.cpp +++ b/test/test_multiset.cpp @@ -1102,5 +1102,40 @@ namespace } } } + + //************************************************************************* + TEST_FIXTURE(SetupFixture, test_erase_bug) + { + using Data = etl::multiset; + + int keys[10] = { 3, 2, 1, 0, 3, 0, 3, 0, 2, 2 }; + + Data data; + + for (int eltNum = 0; eltNum != 10; ++eltNum) + { + data.insert(Data::value_type(keys[eltNum])); + } + + data.erase(2); + + int prv = INT_MAX; + Data::const_reverse_iterator pos; + + bool pass = true; + + for (pos = data.crbegin(); pos != data.crend(); ++pos) + { + if (*pos > prv) + { + pass = false; + break; + } + + prv = *pos; + } + + CHECK(pass); + } }; } diff --git a/test/vs2017/etl.vcxproj b/test/vs2017/etl.vcxproj index d97dbef2..830b1e5f 100644 --- a/test/vs2017/etl.vcxproj +++ b/test/vs2017/etl.vcxproj @@ -221,7 +221,7 @@ false - stdcpp14 + stdcpp17 false @@ -326,6 +326,7 @@ ../../../unittest-cpp/UnitTest++/;../../include;../../include/etl/c;../../test + stdcpp17 Console