From 19259095c6e2e7468de577fcc04e779f3580f2d5 Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Sat, 21 Sep 2024 04:25:16 +0100 Subject: [PATCH] Further gcc -Werror=array-bounds fix In test/perf/startup, gcc (Debian 14.2.0-3) seems to get confused about the size of the counters vector as the code was written. Rewrite the code to pass the same value (`std::thread::hardware_concurrency()`, but in a local) to both `counters.resize()` and the `ParallelTest` ctor. --- src/test/perf/startup/startup.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/test/perf/startup/startup.cc b/src/test/perf/startup/startup.cc index d1e999a2f..437128f05 100644 --- a/src/test/perf/startup/startup.cc +++ b/src/test/perf/startup/startup.cc @@ -70,7 +70,8 @@ class ParallelTest int main() { - counters.resize(std::thread::hardware_concurrency()); + auto nthreads = std::thread::hardware_concurrency(); + counters.resize(nthreads); ParallelTest test( [](size_t id) { @@ -80,7 +81,7 @@ int main() auto end = Aal::tick(); counters[id] = end - start; }, - counters.size()); + nthreads); std::cout << "Taken: " << test.time() << std::endl; std::sort(counters.begin(), counters.end());