You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by ap...@apache.org on 2022/06/07 16:20:46 UTC
[arrow] branch master updated: ARROW-16725: [C++] Fix compilation warnings in release mode (#13293)
This is an automated email from the ASF dual-hosted git repository.
apitrou pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new 9b7eb4dd72 ARROW-16725: [C++] Fix compilation warnings in release mode (#13293)
9b7eb4dd72 is described below
commit 9b7eb4dd72537ebf70e69183a6c96828039d90e7
Author: Antoine Pitrou <an...@python.org>
AuthorDate: Tue Jun 7 18:20:41 2022 +0200
ARROW-16725: [C++] Fix compilation warnings in release mode (#13293)
As seen on e.g. MinGW CI builds.
Authored-by: Antoine Pitrou <an...@python.org>
Signed-off-by: Antoine Pitrou <an...@python.org>
---
cpp/src/arrow/compute/exec/ir_consumer.cc | 2 +-
cpp/src/arrow/compute/kernels/scalar_arithmetic_test.cc | 4 ++--
cpp/src/arrow/compute/kernels/vector_sort.cc | 11 ++++++-----
cpp/src/arrow/ipc/reader.cc | 2 +-
cpp/src/arrow/python/python_to_arrow.cc | 2 +-
cpp/src/arrow/testing/json_internal.cc | 2 +-
6 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/cpp/src/arrow/compute/exec/ir_consumer.cc b/cpp/src/arrow/compute/exec/ir_consumer.cc
index 8627530d43..0aafa2c281 100644
--- a/cpp/src/arrow/compute/exec/ir_consumer.cc
+++ b/cpp/src/arrow/compute/exec/ir_consumer.cc
@@ -625,7 +625,7 @@ Result<Declaration> Convert(const ir::Relation& rel) {
break;
}
- NullPlacement key_null_placement;
+ NullPlacement key_null_placement{};
switch (key->ordering()) {
case ir::Ordering::ASCENDING_THEN_NULLS:
case ir::Ordering::DESCENDING_THEN_NULLS:
diff --git a/cpp/src/arrow/compute/kernels/scalar_arithmetic_test.cc b/cpp/src/arrow/compute/kernels/scalar_arithmetic_test.cc
index 0504049f69..be8a445c74 100644
--- a/cpp/src/arrow/compute/kernels/scalar_arithmetic_test.cc
+++ b/cpp/src/arrow/compute/kernels/scalar_arithmetic_test.cc
@@ -3338,15 +3338,15 @@ TYPED_TEST(TestUnaryArithmeticIntegral, Sqrt) {
TYPED_TEST(TestUnaryArithmeticFloating, Sqrt) {
using CType = typename TestFixture::CType;
this->SetNansEqual(true);
- auto min_val = std::numeric_limits<CType>::min();
- auto max_val = std::numeric_limits<CType>::max();
for (auto check_overflow : {false, true}) {
+ const auto min_val = std::numeric_limits<CType>::min();
this->SetOverflowCheck(check_overflow);
this->AssertUnaryOp(Sqrt, "[1, 2, null, NaN, Inf]",
"[1, 1.414213562, null, NaN, Inf]");
this->AssertUnaryOp(Sqrt, min_val, static_cast<CType>(std::sqrt(min_val)));
#ifndef __MINGW32__
// this is problematic and produces a slight difference on MINGW
+ const auto max_val = std::numeric_limits<CType>::max();
this->AssertUnaryOp(Sqrt, max_val, static_cast<CType>(std::sqrt(max_val)));
#endif
}
diff --git a/cpp/src/arrow/compute/kernels/vector_sort.cc b/cpp/src/arrow/compute/kernels/vector_sort.cc
index 93ed8a7860..28307ecca3 100644
--- a/cpp/src/arrow/compute/kernels/vector_sort.cc
+++ b/cpp/src/arrow/compute/kernels/vector_sort.cc
@@ -1968,7 +1968,7 @@ class ArrayRanker : public TypeVisitor {
switch (tiebreaker_) {
case RankOptions::Dense: {
- T curr_value, prev_value;
+ T curr_value, prev_value{};
rank = 0;
if (null_placement_ == NullPlacement::AtStart && sorted.null_count() > 0) {
@@ -2006,10 +2006,11 @@ class ArrayRanker : public TypeVisitor {
}
case RankOptions::Min: {
- T curr_value, prev_value;
+ T curr_value, prev_value{};
+ rank = 0;
if (null_placement_ == NullPlacement::AtStart) {
- rank = 1;
+ rank++;
for (auto it = sorted.nulls_begin; it < sorted.nulls_end; it++) {
out_begin[*it] = rank;
}
@@ -2035,10 +2036,10 @@ class ArrayRanker : public TypeVisitor {
case RankOptions::Max: {
// The algorithm for Max is just like Min, but in reverse order.
- T curr_value, prev_value;
+ T curr_value, prev_value{};
+ rank = length;
if (null_placement_ == NullPlacement::AtEnd) {
- rank = length;
for (auto it = sorted.nulls_begin; it < sorted.nulls_end; it++) {
out_begin[*it] = rank;
}
diff --git a/cpp/src/arrow/ipc/reader.cc b/cpp/src/arrow/ipc/reader.cc
index f25f16b4e4..c580add4f4 100644
--- a/cpp/src/arrow/ipc/reader.cc
+++ b/cpp/src/arrow/ipc/reader.cc
@@ -2308,7 +2308,7 @@ Status CheckSparseTensorBodyBufferCount(const IpcPayload& payload,
} // namespace
Result<size_t> ReadSparseTensorBodyBufferCount(const Buffer& metadata) {
- SparseTensorFormat::type format_id;
+ SparseTensorFormat::type format_id{};
std::vector<int64_t> shape;
RETURN_NOT_OK(internal::GetSparseTensorMetadata(metadata, nullptr, &shape, nullptr,
diff --git a/cpp/src/arrow/python/python_to_arrow.cc b/cpp/src/arrow/python/python_to_arrow.cc
index e72e127da8..0379cf7e9e 100644
--- a/cpp/src/arrow/python/python_to_arrow.cc
+++ b/cpp/src/arrow/python/python_to_arrow.cc
@@ -1135,7 +1135,7 @@ Result<std::shared_ptr<ChunkedArray>> ConvertPySequence(PyObject* obj, PyObject*
MemoryPool* pool) {
PyAcquireGIL lock;
- PyObject* seq;
+ PyObject* seq = nullptr;
OwnedRef tmp_seq_nanny;
ARROW_ASSIGN_OR_RAISE(auto is_pandas_imported, internal::IsModuleImported("pandas"));
diff --git a/cpp/src/arrow/testing/json_internal.cc b/cpp/src/arrow/testing/json_internal.cc
index b6f942ae10..c88e95df01 100644
--- a/cpp/src/arrow/testing/json_internal.cc
+++ b/cpp/src/arrow/testing/json_internal.cc
@@ -1148,7 +1148,7 @@ Status GetField(const rj::Value& obj, FieldPosition field_pos,
// Parse dictionary id in JSON and add dictionary field to the
// memo, and parse the dictionaries later
RETURN_NOT_OBJECT("dictionary", it_dictionary, json_field);
- bool is_ordered;
+ bool is_ordered{};
std::shared_ptr<DataType> index_type;
RETURN_NOT_OK(ParseDictionary(it_dictionary->value.GetObject(), &dictionary_id,
&is_ordered, &index_type));