aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/ast
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-08-14 23:34:04 +0800
committerGitHub <noreply@github.com>2018-08-14 23:34:04 +0800
commit3f42118d1987ce99b6088d7076b32413373dd09c (patch)
tree8dc85185331dfebec1641993128a0a145ffb48f7 /libsolidity/ast
parent34d3000dcc20cbcf0e0eb71c71fb43403a9db9d8 (diff)
parent43bda534102c95a85daddc64fb466eb8c88e2325 (diff)
downloaddexon-solidity-3f42118d1987ce99b6088d7076b32413373dd09c.tar.gz
dexon-solidity-3f42118d1987ce99b6088d7076b32413373dd09c.tar.zst
dexon-solidity-3f42118d1987ce99b6088d7076b32413373dd09c.zip
Merge pull request #4765 from ethereum/fixes-issue-4673
[WIP] Fixes issue where computing storage size for a number would take too long (or even cause a crash).
Diffstat (limited to 'libsolidity/ast')
-rw-r--r--libsolidity/ast/Types.cpp3
-rw-r--r--libsolidity/ast/Types.h3
2 files changed, 4 insertions, 2 deletions
diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp
index 9e815ca8..68c201a8 100644
--- a/libsolidity/ast/Types.cpp
+++ b/libsolidity/ast/Types.cpp
@@ -1278,7 +1278,8 @@ shared_ptr<FixedPointType const> RationalNumberType::fixedPointType() const
return shared_ptr<FixedPointType const>();
// This means we round towards zero for positive and negative values.
bigint v = value.numerator() / value.denominator();
- if (negative)
+
+ if (negative && v != 0)
// modify value to satisfy bit requirements for negative numbers:
// add one bit for sign and decrement because negative numbers can be larger
v = (v - 1) << 1;
diff --git a/libsolidity/ast/Types.h b/libsolidity/ast/Types.h
index cc96ac4b..34f862c3 100644
--- a/libsolidity/ast/Types.h
+++ b/libsolidity/ast/Types.h
@@ -446,7 +446,8 @@ public:
/// @returns the smallest integer type that can hold the value or an empty pointer if not possible.
std::shared_ptr<IntegerType const> integerType() const;
- /// @returns the smallest fixed type that can hold the value or incurs the least precision loss.
+ /// @returns the smallest fixed type that can hold the value or incurs the least precision loss,
+ /// unless the value was truncated, then a suitable type will be chosen to indicate such event.
/// If the integer part does not fit, returns an empty pointer.
std::shared_ptr<FixedPointType const> fixedPointType() const;