Commit 8fcf46ad authored by Nick Terrell's avatar Nick Terrell Committed by Facebook GitHub Bot

Mark destroyItem() as noexcept

Summary:
F14Node{Map,Set} doesn't require `is_nothrow_destructible<value_type>`.  `clear()` and the destructor are both marked `noexcept`, so they will both terminate if the destructor throws. But `erase()` is not marked `noexcept`, so when the destructor throws during `erase()` the value is left in the map. This could be problematic if the value is half destroyed, or if `eraseInto()` is used.

This diff fixes the problem by marking `destroyItem()` as `noexcept`, so `std::terminate` is called whenever the value destructor throws.

Reviewed By: nbronson

Differential Revision: D20604276

fbshipit-source-id: c52c932d78d6ed61368985a749adf77c27a5a0de
parent 5b4eed64
......@@ -640,7 +640,7 @@ class ValueContainerPolicy : public BasePolicy<
}
}
void destroyItem(Item& item) {
void destroyItem(Item& item) noexcept {
Alloc& a = this->alloc();
auto ptr = std::addressof(item);
AllocTraits::destroy(a, ptr);
......@@ -876,7 +876,7 @@ class NodeContainerPolicy
prefetchAddr(std::addressof(*item));
}
void destroyItem(Item& item) {
void destroyItem(Item& item) noexcept {
if (item != nullptr) {
Alloc& a = this->alloc();
AllocTraits::destroy(a, std::addressof(*item));
......@@ -1252,7 +1252,7 @@ class VectorContainerPolicy : public BasePolicy<
prefetchAddr(std::addressof(values_[item]));
}
void destroyItem(Item&) {}
void destroyItem(Item&) noexcept {}
template <typename T>
std::enable_if_t<std::is_nothrow_move_constructible<T>::value>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment