From 685930b69854fa0c11b2a7fc5a5275611e1cee53 Mon Sep 17 00:00:00 2001 From: Horimoto Yasuhiro Date: Fri, 31 Jul 2026 17:28:04 +0900 Subject: [PATCH] GH-50752: [C++][Compute] Fix unused variable warning when ARROW_WITH_RE2 is disabled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change fixes the following build error: ``` /arrow/cpp/src/arrow/compute/kernels/scalar_string_ascii.cc:1753:16: error: unused variable ‘is_utf8’ [-Werror=unused-variable] 1753 | const bool is_utf8 = is_string_or_string_view(batch[0].type()->id()); | ^~~~~~~ ``` The `is_utf8` variable introduced by commit 374db36 is unused when `ARROW_WITH_RE2=OFF` is specified. ```diff static Status Exec(KernelContext* ctx, const ExecSpan& batch, ExecResult* out) { const MatchSubstringOptions& options = MatchSubstringState::Get(ctx); + const bool is_utf8 = is_string_or_string_view(batch[0].type()->id()); if (options.ignore_case) { ARROW_ASSIGN_OR_RAISE(auto matcher, - FindSubstringRegex::Make(options, InputType::is_utf8, true)); - applicator::ScalarUnaryNotNullStateful + FindSubstringRegex::Make(options, is_utf8, true)); + applicator::ScalarUnaryNotNullStateful kernel{std::move(matcher)}; return kernel.Exec(ctx, batch, out); return Status::NotImplemented("ignore_case requires RE2"); } - applicator::ScalarUnaryNotNullStateful kernel{ - FindSubstring(PlainSubstringMatcher(options))}; + applicator::ScalarUnaryNotNullStateful + kernel{FindSubstring(PlainSubstringMatcher(options))}; return kernel.Exec(ctx, batch, out); } }; ``` Therefore, I move the declaration of `is_utf8` inside the `#ifdef ARROW_WITH_RE2` block to prevent this error. Yes. This change only moves the declaration of `is_utf8` and does not change any logic. Therefore, the existing tests introduced by 374db36 should continue to pass. These tests are already covered by CI, and CI passes successfully with this change. No new tests are added because this change only moves a variable declaration and does not affect behavior. No. - GitHub Issue: GH-50752 --- cpp/src/arrow/compute/kernels/scalar_string_ascii.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/src/arrow/compute/kernels/scalar_string_ascii.cc b/cpp/src/arrow/compute/kernels/scalar_string_ascii.cc index 06ec8c999c61..8e7b626837fe 100644 --- a/cpp/src/arrow/compute/kernels/scalar_string_ascii.cc +++ b/cpp/src/arrow/compute/kernels/scalar_string_ascii.cc @@ -1750,9 +1750,9 @@ struct FindSubstringExec { static Status Exec(KernelContext* ctx, const ExecSpan& batch, ExecResult* out) { const MatchSubstringOptions& options = MatchSubstringState::Get(ctx); - const bool is_utf8 = is_string_or_string_view(batch[0].type()->id()); if (options.ignore_case) { #ifdef ARROW_WITH_RE2 + const bool is_utf8 = is_string_or_string_view(batch[0].type()->id()); ARROW_ASSIGN_OR_RAISE(auto matcher, FindSubstringRegex::Make(options, is_utf8, true)); applicator::ScalarUnaryNotNullStateful