Copilot commented on code in PR #51169:
URL: https://github.com/apache/arrow/pull/51169#discussion_r3944360018
##########
cpp/src/arrow/util/decimal.cc:
##########
@@ -962,9 +985,9 @@ Status SimpleDecimalFromString(const char* type_name,
std::string_view s,
if (out != nullptr) {
uint64_t value{0};
- ShiftAndAdd(dec.whole_digits, &value, 1);
- ShiftAndAdd(dec.fractional_digits, &value, 1);
- if (value > static_cast<uint64_t>(
+ if (ShiftAndAddWithOverflow(dec.whole_digits, &value, 1) ||
+ ShiftAndAddWithOverflow(dec.fractional_digits, &value, 1) ||
+ value > static_cast<uint64_t>(
std::numeric_limits<typename
DecimalClass::ValueType>::max())) {
return Status::Invalid("The string '", s, "' cannot be represented as ",
type_name);
Review Comment:
SimpleDecimalFromString rejects the minimum negative value for
Decimal32/Decimal64. For example, parsing "-2147483648" /
"-9223372036854775808" should be representable in two’s complement, but the
current check `value > max()` rejects it before applying the sign.
--
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]