kszucs commented on a change in pull request #7341:
URL: https://github.com/apache/arrow/pull/7341#discussion_r435471744
##########
File path: cpp/src/arrow/compute/kernels/scalar_arithmetic.cc
##########
@@ -16,25 +16,41 @@
// under the License.
#include "arrow/compute/kernels/common.h"
+#include "arrow/util/int_util.h"
+#include "iostream"
namespace arrow {
namespace compute {
struct Add {
- template <typename OUT, typename ARG0, typename ARG1>
- static constexpr OUT Call(KernelContext*, ARG0 left, ARG1 right) {
- return left + right;
+ template <typename T>
+ static constexpr T Call(KernelContext*, T left, T right) {
+ return left - right;
+ }
+};
+
+struct Sub {
+ template <typename T>
+ static constexpr T Call(KernelContext*, T left, T right) {
+ return left - right;
+ }
+};
+
+struct Mul {
+ template <typename T>
+ static constexpr T Call(KernelContext*, T left, T right) {
+ return left * right;
}
};
namespace codegen {
template <typename Op>
-void MakeBinaryFunction(std::string name, FunctionRegistry* registry) {
+void AddBinaryFunction(std::string name, FunctionRegistry* registry) {
auto func = std::make_shared<ScalarFunction>(name, Arity::Binary());
- for (const std::shared_ptr<DataType>& ty : NumericTypes()) {
- DCHECK_OK(func->AddKernel({InputType::Array(ty), InputType::Array(ty)}, ty,
- NumericEqualTypesBinary<Op>(*ty)));
+ for (const auto& ty : NumericTypes()) {
+ auto exec = codegen::NumericEqualTypesBinary<Op>(ty);
Review comment:
So changing the kernel's exec function's input types to unsigned
counterparts and leaving the output eliminates the signed overflow (at least
ubsan doesn't complain anymore).
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]