From b76a1b3604f8e645402a68c3352e1bc360a5b8f9 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Tue, 13 Nov 2018 23:44:39 +0000 Subject: [PATCH] Fix error when selecting number of memory pools * src/c++17/memory_resource.cc (select_num_pools): Fix off-by-one error when block_size is equal to one of the values in the array. From-SVN: r266092 --- libstdc++-v3/ChangeLog | 3 +++ libstdc++-v3/src/c++17/memory_resource.cc | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 03aaeca1af5..4ea9dbfc18a 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,8 @@ 2018-11-13 Jonathan Wakely + * src/c++17/memory_resource.cc (select_num_pools): Fix off-by-one + error when block_size is equal to one of the values in the array. + * src/c++17/memory_resource.cc (_Pool::deallocate): Restore attributes to parameters that are only used in assertions. diff --git a/libstdc++-v3/src/c++17/memory_resource.cc b/libstdc++-v3/src/c++17/memory_resource.cc index cb91e5147ce..605bdd53950 100644 --- a/libstdc++-v3/src/c++17/memory_resource.cc +++ b/libstdc++-v3/src/c++17/memory_resource.cc @@ -892,7 +892,7 @@ namespace pmr auto p = std::lower_bound(std::begin(pool_sizes), std::end(pool_sizes), opts.largest_required_pool_block); const int n = p - std::begin(pool_sizes); - if (p == std::end(pool_sizes) || *p == opts.largest_required_pool_block) + if (p == std::end(pool_sizes)) return n; return n + 1; } -- 2.30.2