From da28face2c76b395a642b4e833853f5c677dfaff Mon Sep 17 00:00:00 2001 From: sfc-gh-tclinkenbeard Date: Fri, 10 Jul 2020 11:42:56 -0700 Subject: [PATCH] Avoid throwing while relocating Deque contents --- flow/Deque.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/flow/Deque.h b/flow/Deque.h index c5c05fb895..ac5596f4b6 100644 --- a/flow/Deque.h +++ b/flow/Deque.h @@ -168,10 +168,11 @@ private: if (newSize > max_size()) throw std::bad_alloc(); //printf("Growing to %lld (%u-%u mask %u)\n", (long long)newSize, begin, end, mask); T* newArr = (T*)aligned_alloc(std::max(__alignof(T), sizeof(void*)), - newSize * sizeof(T)); // SOMEDAY: FastAllocator, exception safety + newSize * sizeof(T)); // SOMEDAY: FastAllocator ASSERT(newArr != nullptr); for (int i = begin; i != end; i++) { - new (&newArr[i - begin]) T(std::move(arr[i&mask])); + new (&newArr[i - begin]) T(std::move_if_noexcept(arr[i & mask])); + static_assert(std::is_nothrow_destructible_v); arr[i&mask].~T(); } aligned_free(arr);