[libcxx-commits] [libcxx] dac66ca - [libc++] Fix dangling reference in the associative container benchmarks (#213139)
via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Jul 31 10:21:26 PDT 2026
Author: Louis Dionne
Date: 2026-07-31T13:21:21-04:00
New Revision: dac66ca4776b18304249bb3a37f08915e5ad1bf4
URL: https://github.com/llvm/llvm-project/commit/dac66ca4776b18304249bb3a37f08915e5ad1bf4
DIFF: https://github.com/llvm/llvm-project/commit/dac66ca4776b18304249bb3a37f08915e5ad1bf4.diff
LOG: [libc++] Fix dangling reference in the associative container benchmarks (#213139)
Two insert benchmarks were registered with lambdas capturing insert_iter_iter_bench
by reference, unlike every other registration in this file, which captures by value.
RegisterBenchmark() stores the lambda by value and only invokes it from
RunSpecifiedBenchmarks(), which happens long after associative_container_benchmarks()
has returned, creating a dangling reference.
Added:
Modified:
libcxx/test/benchmarks/containers/associative/associative_container_benchmarks.h
Removed:
################################################################################
diff --git a/libcxx/test/benchmarks/containers/associative/associative_container_benchmarks.h b/libcxx/test/benchmarks/containers/associative/associative_container_benchmarks.h
index b45ef28075177..a6fc117f2c867 100644
--- a/libcxx/test/benchmarks/containers/associative/associative_container_benchmarks.h
+++ b/libcxx/test/benchmarks/containers/associative/associative_container_benchmarks.h
@@ -498,9 +498,9 @@ void associative_container_benchmarks(std::string container) {
st.ResumeTiming();
}
};
- bench("insert(iterator, iterator) (all new keys, end)", [&](auto& state) { insert_iter_iter_bench(true, state); });
+ bench("insert(iterator, iterator) (all new keys, end)", [=](auto& state) { insert_iter_iter_bench(true, state); });
bench("insert(iterator, iterator) (all new keys, middle)",
- [&](auto& state) { insert_iter_iter_bench(false, state); });
+ [=](auto& state) { insert_iter_iter_bench(false, state); });
bench("insert(iterator, iterator) (half new keys)", [=](auto& st) {
const std::size_t size = st.range(0);
More information about the libcxx-commits
mailing list