diff --git a/cpp/src/arrow/compute/kernels/scalar_string_ascii.cc b/cpp/src/arrow/compute/kernels/scalar_string_ascii.cc index aa6771b81c8c9..ffbcaf53656f0 100644 --- a/cpp/src/arrow/compute/kernels/scalar_string_ascii.cc +++ b/cpp/src/arrow/compute/kernels/scalar_string_ascii.cc @@ -2590,7 +2590,8 @@ struct SliceBytesTransform : StringSliceTransformBase { start = std::min(start, input_width); stop = std::min(stop, input_width); - if ((start >= stop and step > 0) || (start <= stop and step < 0) || start == stop) { + if ((start == stop) || ((start >= stop) && (step > 0)) || + ((start <= stop) && (step < 0))) { return 0; } return static_cast(std::max(