rok commented on a change in pull request #9841: URL: https://github.com/apache/arrow/pull/9841#discussion_r609144655
########## File path: cpp/src/arrow/compute/kernels/scalar_arithmetic.cc ########## @@ -233,6 +236,104 @@ struct DivideChecked { } }; +template <typename T> +inline T integer_power(KernelContext* ctx, T left, T right) { + if (right < 0) { + ctx->SetStatus( + Status::Invalid("integers to negative integer powers are not allowed")); + } + T result = 1; + if (left == 0 && right != 0) { + return 0; + } + while (true) { + if (right % 2) { + result *= left; Review comment: Weird - I've set the flag but don't get the overflow error locally, while [CI reports](https://github.com/apache/arrow/pull/9841/checks?check_run_id=2292038374#step:8:2054): ``` [ RUN ] TestBinaryArithmeticIntegral/2.Power /arrow/cpp/src/arrow/compute/kernels/scalar_arithmetic.cc:256:10: runtime error: signed integer overflow: 2147483647 * 2147483647 cannot be represented in type 'int' ``` Any tips? -- 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: us...@infra.apache.org