Fix wrong assert in overflow check

This commit is contained in:
Mathias Baumann 2019-10-21 15:14:20 +02:00
parent e56d1aa5aa
commit c3e8023ad5
3 changed files with 12 additions and 1 deletions

View File

@ -9,6 +9,7 @@ Compiler Features:
Bugfixes:
* Type Checker: Disallow constructor of the same class to be used as modifier
* Code Generator: Fixed a faulty assert that would wrongly trigger for array sizes exceeding unsigned integer

View File

@ -1849,7 +1849,7 @@ u256 ArrayType::memoryDataSize() const
solAssert(m_location == DataLocation::Memory, "");
solAssert(!isByteArray(), "");
bigint size = bigint(m_length) * m_baseType->memoryHeadSize();
solAssert(size <= numeric_limits<unsigned>::max(), "Array size does not fit u256.");
solAssert(size <= numeric_limits<u256>::max(), "Array size does not fit u256.");
return u256(size);
}

View File

@ -0,0 +1,10 @@
// Used to cause ICE because of a too strict assert
pragma experimental ABIEncoderV2;
contract C {
struct S { uint a; T[222222222222222222222222222] sub; }
struct T { uint[] x; }
function f() public returns (uint, S memory) {
}
}
// ----
// Warning: (52-85): Experimental features are turned on. Do not use experimental features on live deployments.