Skip to content

Commit

Permalink
Further gcc -Werror=array-bounds fix
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nwf committed Sep 21, 2024
1 parent d537d35 commit 1925909
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/test/perf/startup/startup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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());
Expand Down

0 comments on commit 1925909

Please sign in to comment.