Skip to content

Commit

Permalink
MINOR: [C++] Fix a maybe-uninitialized warning (apache#38433)
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Sutou Kouhei <[email protected]>
  • Loading branch information
js8544 authored and loicalleyne committed Nov 13, 2023
1 parent df65468 commit b1a958d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cpp/src/arrow/compute/kernels/scalar_round.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,7 @@ std::shared_ptr<ScalarFunction> MakeUnaryRoundFunction(std::string name,
RoundKernelGenerator<Op, RoundKernel, OptionsType> 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(
Expand All @@ -1280,7 +1280,7 @@ std::shared_ptr<ScalarFunction> MakeBinaryRoundFunction(const std::string& name,
RoundKernelGenerator<Op, RoundBinaryKernel, OptionsType> 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(
Expand Down

0 comments on commit b1a958d

Please sign in to comment.