Fix error when selecting number of memory pools
authorJonathan Wakely <jwakely@redhat.com>
Tue, 13 Nov 2018 23:44:39 +0000 (23:44 +0000)
committerJonathan Wakely <redi@gcc.gnu.org>
Tue, 13 Nov 2018 23:44:39 +0000 (23:44 +0000)
* 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
libstdc++-v3/src/c++17/memory_resource.cc

index 03aaeca1af55bb4cfc5fc77d8caeef9019987ba3..4ea9dbfc18afe9fc79f47601e935b6dbed2fd946 100644 (file)
@@ -1,5 +1,8 @@
 2018-11-13  Jonathan Wakely  <jwakely@redhat.com>
 
+       * 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.
 
index cb91e5147cec72ceb7012d0143a11b7434135aed..605bdd53950b05c93f677618018d474288d59e92 100644 (file)
@@ -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;
   }