From 67bb53169b91155491be995e2efec4d6de24d492 Mon Sep 17 00:00:00 2001 From: William Ayd Date: Tue, 16 Apr 2024 04:30:30 -0400 Subject: [PATCH] GH-38889: [C++] Fix redundant move warnings (#41107) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Though the original issue was closed, I am also seeing this warning when compiling nanoarrow ``` [13/91] Compiling C++ object src/nanoarrow/utils_test.p/utils_test.cc.o FAILED: src/nanoarrow/utils_test.p/utils_test.cc.o c++ -Isrc/nanoarrow/utils_test.p -Isrc/nanoarrow -I../src/nanoarrow -Isrc -I../src -I/home/arrow-nanoarrow/arrow/include -fdiagnostics-color=always -D_GLIBCXX_ASSERTIONS=1 -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -Werror -std=c++17 -O3 -pthread -isystem../subprojects/googletest-1.14.0/googletest -isystemsubprojects/googletest-1.14.0/googletest -isystem../subprojects/googletest-1.14.0/googletest/include -MD -MQ src/nanoarrow/utils_test.p/utils_test.cc.o -MF src/nanoarrow/utils_test.p/utils_test.cc.o.d -o src/nanoarrow/utils_test.p/utils_test.cc.o -c ../src/nanoarrow/utils_test.cc In file included from ../src/nanoarrow/utils_test.cc:21: /home/arrow-nanoarrow/arrow/include/arrow/util/decimal.h: In member function ‘arrow::Result > arrow::Decimal128::Divide(const arrow::Decimal128&) const’: /home/arrow-nanoarrow/arrow/include/arrow/util/decimal.h:83:21: error: redundant move in return statement [-Werror=redundant-move] 83 | return std::move(result); | ~~~~~~~~~^~~~~~~~ /home/arrow-nanoarrow/arrow/include/arrow/util/decimal.h:83:21: note: remove ‘std::move’ call /home/arrow-nanoarrow/arrow/include/arrow/util/decimal.h: In member function ‘arrow::Result arrow::Decimal128::Rescale(int32_t, int32_t) const’: /home/arrow-nanoarrow/arrow/include/arrow/util/decimal.h:121:21: error: redundant move in return statement [-Werror=redundant-move] 121 | return std::move(out); | ~~~~~~~~~^~~~~ /home/arrow-nanoarrow/arrow/include/arrow/util/decimal.h:121:21: note: remove ‘std::move’ call /home/arrow-nanoarrow/arrow/include/arrow/util/decimal.h: In member function ‘arrow::Result arrow::Decimal256::Rescale(int32_t, int32_t) const’: /home/arrow-nanoarrow/arrow/include/arrow/util/decimal.h:221:21: error: redundant move in return statement [-Werror=redundant-move] 221 | return std::move(out); | ~~~~~~~~~^~~~~ /home/arrow-nanoarrow/arrow/include/arrow/util/decimal.h:221:21: note: remove ‘std::move’ call /home/arrow-nanoarrow/arrow/include/arrow/util/decimal.h: In member function ‘arrow::Result > arrow::Decimal256::Divide(const arrow::Decimal256&) const’: /home/arrow-nanoarrow/arrow/include/arrow/util/decimal.h:238:21: error: redundant move in return statement [-Werror=redundant-move] 238 | return std::move(result); | ~~~~~~~~~^~~~~~~~ /home/arrow-nanoarrow/arrow/include/arrow/util/decimal.h:238:21: note: remove ‘std::move’ call ``` * GitHub Issue: #38889 ### Rationale for this change Helps clean up build warnings when compiling with -Wextra ### What changes are included in this PR? Removed std::move from some return statements ### Are these changes tested? N/A - just ensured program compiles cleanly ### Are there any user-facing changes? No Authored-by: Will Ayd Signed-off-by: Antoine Pitrou --- cpp/src/arrow/util/decimal.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cpp/src/arrow/util/decimal.h b/cpp/src/arrow/util/decimal.h index 345c74d95b101..14c7103d5ac0d 100644 --- a/cpp/src/arrow/util/decimal.h +++ b/cpp/src/arrow/util/decimal.h @@ -80,7 +80,7 @@ class ARROW_EXPORT Decimal128 : public BasicDecimal128 { std::pair result; auto dstatus = BasicDecimal128::Divide(divisor, &result.first, &result.second); ARROW_RETURN_NOT_OK(ToArrowStatus(dstatus)); - return std::move(result); + return result; } /// \brief Convert the Decimal128 value to a base 10 decimal string with the given @@ -118,7 +118,7 @@ class ARROW_EXPORT Decimal128 : public BasicDecimal128 { Decimal128 out; auto dstatus = BasicDecimal128::Rescale(original_scale, new_scale, &out); ARROW_RETURN_NOT_OK(ToArrowStatus(dstatus)); - return std::move(out); + return out; } /// \brief Convert to a signed integer @@ -218,7 +218,7 @@ class ARROW_EXPORT Decimal256 : public BasicDecimal256 { Decimal256 out; auto dstatus = BasicDecimal256::Rescale(original_scale, new_scale, &out); ARROW_RETURN_NOT_OK(ToArrowStatus(dstatus)); - return std::move(out); + return out; } /// Divide this number by right and return the result. @@ -235,7 +235,7 @@ class ARROW_EXPORT Decimal256 : public BasicDecimal256 { std::pair result; auto dstatus = BasicDecimal256::Divide(divisor, &result.first, &result.second); ARROW_RETURN_NOT_OK(ToArrowStatus(dstatus)); - return std::move(result); + return result; } /// \brief Convert from a big-endian byte representation. The length must be