diff --git a/cpp/src/arrow/compute/kernels/aggregate_internal.h b/cpp/src/arrow/compute/kernels/aggregate_internal.h index 8db74bfe0cd80..8fd67485d7fb1 100644 --- a/cpp/src/arrow/compute/kernels/aggregate_internal.h +++ b/cpp/src/arrow/compute/kernels/aggregate_internal.h @@ -164,7 +164,8 @@ enable_if_t::value, SumType> SumArray( // reduce summation of one block (may be smaller than kBlockSize) from leaf node // continue reducing to upper level if two summations are ready for non-leaf node - auto reduce = [&](SumType block_sum) { + // (capture `levels` by value because of ARROW-17567) + auto reduce = [&, levels](SumType block_sum) { int cur_level = 0; uint64_t cur_level_mask = 1ULL; sum[cur_level] += block_sum; diff --git a/cpp/src/arrow/compute/kernels/scalar_set_lookup.cc b/cpp/src/arrow/compute/kernels/scalar_set_lookup.cc index 7a0834058f07f..292a924233b49 100644 --- a/cpp/src/arrow/compute/kernels/scalar_set_lookup.cc +++ b/cpp/src/arrow/compute/kernels/scalar_set_lookup.cc @@ -67,8 +67,11 @@ struct SetLookupState : public KernelState { auto visit_valid = [&](T v) { const auto memo_size = static_cast(memo_index_to_value_index.size()); int32_t unused_memo_index; - auto on_found = [&](int32_t memo_index) { DCHECK_LT(memo_index, memo_size); }; - auto on_not_found = [&](int32_t memo_index) { + // (capture `memo_size` by value because of ARROW-17567) + auto on_found = [&, memo_size](int32_t memo_index) { + DCHECK_LT(memo_index, memo_size); + }; + auto on_not_found = [&, memo_size](int32_t memo_index) { DCHECK_EQ(memo_index, memo_size); memo_index_to_value_index.push_back(index); }; @@ -79,8 +82,10 @@ struct SetLookupState : public KernelState { }; auto visit_null = [&]() { const auto memo_size = static_cast(memo_index_to_value_index.size()); - auto on_found = [&](int32_t memo_index) { DCHECK_LT(memo_index, memo_size); }; - auto on_not_found = [&](int32_t memo_index) { + auto on_found = [&, memo_size](int32_t memo_index) { + DCHECK_LT(memo_index, memo_size); + }; + auto on_not_found = [&, memo_size](int32_t memo_index) { DCHECK_EQ(memo_index, memo_size); memo_index_to_value_index.push_back(index); };