From b1a958d53322062ef74ed4964b3a92b9dfa2bb2e Mon Sep 17 00:00:00 2001 From: Jin Shang Date: Wed, 25 Oct 2023 13:55:19 +0800 Subject: [PATCH] MINOR: [C++] Fix a maybe-uninitialized warning (#38433) Some compilers generate a maybe-uninitialized warning when compiling scalar_round.cc ``` /home/jinshang/arrow/cpp/src/arrow/util/logging.h: In function 'void arrow::compute::internal::RegisterScalarRoundArithmetic(arrow::compute::FunctionRegistry*)': /home/jinshang/arrow/cpp/src/arrow/util/logging.h:59:34: warning: 'exec' may be used uninitialized [-Wmaybe-uninitialized] 59 | #define ARROW_IGNORE_EXPR(expr) ((void)(expr)) | ^ /home/jinshang/arrow/cpp/src/arrow/compute/kernels/scalar_round.cc:1262:23: note: 'exec' was declared here 1262 | ArrayKernelExec exec; | ^~~~ /home/jinshang/arrow/cpp/src/arrow/util/logging.h:59:34: warning: 'exec' may be used uninitialized [-Wmaybe-uninitialized] 59 | #define ARROW_IGNORE_EXPR(expr) ((void)(expr)) | ^ /home/jinshang/arrow/cpp/src/arrow/compute/kernels/scalar_round.cc:1283:23: note: 'exec' was declared here 1283 | ArrayKernelExec exec; | ^~~~ ``` Authored-by: Jin Shang Signed-off-by: Sutou Kouhei --- cpp/src/arrow/compute/kernels/scalar_round.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cpp/src/arrow/compute/kernels/scalar_round.cc b/cpp/src/arrow/compute/kernels/scalar_round.cc index 5dc628f8d95c5..36e59c8c1deac 100644 --- a/cpp/src/arrow/compute/kernels/scalar_round.cc +++ b/cpp/src/arrow/compute/kernels/scalar_round.cc @@ -1259,7 +1259,7 @@ std::shared_ptr MakeUnaryRoundFunction(std::string name, RoundKernelGenerator kernel_generator; for (const auto& tys : {NumericTypes(), {decimal128(1, 0), decimal256(1, 0)}}) { for (const auto& ty : tys) { - ArrayKernelExec exec; + ArrayKernelExec exec = nullptr; KernelInit init; DCHECK_OK(VisitTypeInline(*ty, &kernel_generator, &exec, &init)); DCHECK_OK(func->AddKernel( @@ -1280,7 +1280,7 @@ std::shared_ptr MakeBinaryRoundFunction(const std::string& name, RoundKernelGenerator kernel_generator; for (const auto& tys : {NumericTypes(), {decimal128(1, 0), decimal256(1, 0)}}) { for (const auto& ty : tys) { - ArrayKernelExec exec; + ArrayKernelExec exec = nullptr; KernelInit init; DCHECK_OK(VisitTypeInline(*ty, &kernel_generator, &exec, &init)); DCHECK_OK(func->AddKernel(