WillAyd commented on PR #41487:
URL: https://github.com/apache/arrow/pull/41487#issuecomment-2110911293
Well this is fun...looks like the compilers have conflicting desires. With
code like this:
```cpp
template <typename Options, typename... Properties>
const FunctionOptionsType* GetFunctionOptionsType(const Properties&...
properties) {
...
auto options = std::make_unique<Options>();
RETURN_NOT_OK(
FromStructScalarImpl<Options>(options.get(), scalar,
properties_).status_);
return std::move(options);
}
```
The more modern compilers complain about a redundant move:
```sh
/home/willayd/clones/arrow/cpp/src/arrow/compute/function_internal.h: In
instantiation of
‘arrow::Result<std::unique_ptr<arrow::compute::FunctionOptions> >
arrow::compute::internal::GetFunctionOptionsType(const Properties&
...)::OptionsType::FromStructScalar(const arrow::StructScalar&) const [with
Options = arrow::compute::ArithmeticOptions; Properties =
{arrow::internal::DataMemberProperty<arrow::compute::ArithmeticOptions,
bool>}]’:
/home/willayd/clones/arrow/cpp/src/arrow/compute/function_internal.h:697:3:
required from ‘const arrow::compute::FunctionOptionsType*
arrow::compute::internal::GetFunctionOptionsType(const Properties& ...) [with
Options = arrow::compute::ArithmeticOptions; Properties =
{arrow::internal::DataMemberProperty<arrow::compute::ArithmeticOptions, bool>}]’
/home/willayd/clones/arrow/cpp/src/arrow/compute/api_scalar.cc:314:79:
required from here
/home/willayd/clones/arrow/cpp/src/arrow/compute/function_internal.h:687:31:
error: redundant move in return statement [-Werror=redundant-move]
687 | return std::move(options);
```
If you remove the `std::move(...)` then the openSUSE builds complain that
they cannot convert the templated pointer type to that which matches the
function declaration:
```sh
/arrow/cpp/src/arrow/compute/function_internal.h:687:14: error: could not
convert ‘options’ from ‘std::unique_ptr<arrow::compute::ArithmeticOptions,
std::default_delete<arrow::compute::ArithmeticOptions> >’ to
‘arrow::Result<std::unique_ptr<arrow::compute::FunctionOptions> >’
return options;
```
This also seems to happen in cases where the returned value is a unique_ptr
but the function/method declaration is that of a shared_ptr; I'm assuming more
modern compilers happily convert that automatically for you but the compiler on
the openSUSE build does not
For now I've tried to be really explicit about the return type in the
offending functions to try and appease all platforms, but happy to change to
any better idea
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]