Skip to content

Commit

Permalink
apacheGH-38889: [C++] Fix redundant move warnings (apache#41107)
Browse files Browse the repository at this point in the history
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<std::pair<arrow::Decimal128, arrow::Decimal128> > 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> 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> 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<std::pair<arrow::Decimal256, arrow::Decimal256> > 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: apache#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 <[email protected]>
Signed-off-by: Antoine Pitrou <[email protected]>
  • Loading branch information
WillAyd authored and tolleybot committed May 2, 2024
1 parent e71c586 commit 67bb531
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cpp/src/arrow/util/decimal.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class ARROW_EXPORT Decimal128 : public BasicDecimal128 {
std::pair<Decimal128, Decimal128> 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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand All @@ -235,7 +235,7 @@ class ARROW_EXPORT Decimal256 : public BasicDecimal256 {
std::pair<Decimal256, Decimal256> 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
Expand Down

0 comments on commit 67bb531

Please sign in to comment.