mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Reject negative shifts within constants
This commit is contained in:
parent
48f2028911
commit
33250eef9e
@ -710,9 +710,11 @@ TypePointer RationalNumberType::binaryOperatorResult(Token::Value _operator, Typ
|
|||||||
using boost::multiprecision::pow;
|
using boost::multiprecision::pow;
|
||||||
if (fractional)
|
if (fractional)
|
||||||
return TypePointer();
|
return TypePointer();
|
||||||
else if (abs(other.m_value) > numeric_limits<uint32_t>::max())
|
else if (other.m_value < 0)
|
||||||
return TypePointer();
|
return TypePointer();
|
||||||
uint32_t exponent = abs(other.m_value).numerator().convert_to<uint32_t>();
|
else if (other.m_value > numeric_limits<uint32_t>::max())
|
||||||
|
return TypePointer();
|
||||||
|
uint32_t exponent = other.m_value.numerator().convert_to<uint32_t>();
|
||||||
value = m_value.numerator() * pow(bigint(2), exponent);
|
value = m_value.numerator() * pow(bigint(2), exponent);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -721,9 +723,11 @@ TypePointer RationalNumberType::binaryOperatorResult(Token::Value _operator, Typ
|
|||||||
using boost::multiprecision::pow;
|
using boost::multiprecision::pow;
|
||||||
if (fractional)
|
if (fractional)
|
||||||
return TypePointer();
|
return TypePointer();
|
||||||
else if (abs(other.m_value) > numeric_limits<uint32_t>::max())
|
else if (other.m_value < 0)
|
||||||
return TypePointer();
|
return TypePointer();
|
||||||
uint32_t exponent = abs(other.m_value).numerator().convert_to<uint32_t>();
|
else if (other.m_value > numeric_limits<uint32_t>::max())
|
||||||
|
return TypePointer();
|
||||||
|
uint32_t exponent = other.m_value.numerator().convert_to<uint32_t>();
|
||||||
value = rational(m_value.numerator() / pow(bigint(2), exponent), 1);
|
value = rational(m_value.numerator() / pow(bigint(2), exponent), 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user