mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix array copying check.
This commit is contained in:
parent
1b540c175d
commit
bb4e3e191d
@ -2416,7 +2416,7 @@ string YulUtilFunctions::copyArrayFromStorageToMemoryFunction(ArrayType const& _
|
|||||||
return m_functionCollector.createFunction(functionName, [&]() {
|
return m_functionCollector.createFunction(functionName, [&]() {
|
||||||
if (_from.baseType()->isValueType())
|
if (_from.baseType()->isValueType())
|
||||||
{
|
{
|
||||||
solAssert(_from.baseType() == _to.baseType(), "");
|
solAssert(*_from.baseType() == *_to.baseType(), "");
|
||||||
ABIFunctions abi(m_evmVersion, m_revertStrings, m_functionCollector);
|
ABIFunctions abi(m_evmVersion, m_revertStrings, m_functionCollector);
|
||||||
return Whiskers(R"(
|
return Whiskers(R"(
|
||||||
function <functionName>(slot) -> memPtr {
|
function <functionName>(slot) -> memPtr {
|
||||||
|
@ -0,0 +1,43 @@
|
|||||||
|
pragma abicoder v2;
|
||||||
|
|
||||||
|
type Small is uint16;
|
||||||
|
type Left is bytes2;
|
||||||
|
struct S { uint8 a; Small b; Left c; uint8 d; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
S public s;
|
||||||
|
Small[] public small;
|
||||||
|
Left[] public l;
|
||||||
|
function f(S calldata _s) external {
|
||||||
|
s = _s;
|
||||||
|
}
|
||||||
|
function g(Small[] calldata _small) external returns (Small[] memory) {
|
||||||
|
small = _small;
|
||||||
|
return small;
|
||||||
|
}
|
||||||
|
function h(Left[] calldata _left) external returns (Left[] memory) {
|
||||||
|
l = _left;
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ====
|
||||||
|
// compileViaYul: also
|
||||||
|
// ----
|
||||||
|
// s() -> 0, 0, 0x00, 0
|
||||||
|
// f((uint8,uint16,bytes2,uint8)): 1, 0xff, "ab", 15 ->
|
||||||
|
// gas irOptimized: 110778
|
||||||
|
// gas legacy: 112851
|
||||||
|
// gas legacyOptimized: 110766
|
||||||
|
// s() -> 1, 0xff, 0x6162000000000000000000000000000000000000000000000000000000000000, 15
|
||||||
|
// g(uint16[]): 0x20, 3, 1, 2, 3 -> 0x20, 3, 1, 2, 3
|
||||||
|
// gas irOptimized: 112669
|
||||||
|
// gas legacy: 113715
|
||||||
|
// gas legacyOptimized: 112488
|
||||||
|
// small(uint256): 0 -> 1
|
||||||
|
// small(uint256): 1 -> 2
|
||||||
|
// h(bytes2[]): 0x20, 3, "ab", "cd", "ef" -> 0x20, 3, "ab", "cd", "ef"
|
||||||
|
// gas irOptimized: 112797
|
||||||
|
// gas legacy: 113414
|
||||||
|
// gas legacyOptimized: 112572
|
||||||
|
// l(uint256): 0 -> 0x6162000000000000000000000000000000000000000000000000000000000000
|
||||||
|
// l(uint256): 1 -> 0x6364000000000000000000000000000000000000000000000000000000000000
|
@ -0,0 +1,43 @@
|
|||||||
|
pragma abicoder v2;
|
||||||
|
|
||||||
|
type Small is uint16;
|
||||||
|
type Left is bytes2;
|
||||||
|
struct S { uint8 a; Small b; Left c; uint8 d; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
S public s;
|
||||||
|
Small[] public small;
|
||||||
|
Left[] public l;
|
||||||
|
function f(S memory _s) public {
|
||||||
|
s = _s;
|
||||||
|
}
|
||||||
|
function g(Small[] memory _small) public returns (Small[] memory) {
|
||||||
|
small = _small;
|
||||||
|
return small;
|
||||||
|
}
|
||||||
|
function h(Left[] memory _left) public returns (Left[] memory) {
|
||||||
|
l = _left;
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ====
|
||||||
|
// compileViaYul: also
|
||||||
|
// ----
|
||||||
|
// s() -> 0, 0, 0x00, 0
|
||||||
|
// f((uint8,uint16,bytes2,uint8)): 1, 0xff, "ab", 15 ->
|
||||||
|
// gas irOptimized: 110788
|
||||||
|
// gas legacy: 111668
|
||||||
|
// gas legacyOptimized: 110908
|
||||||
|
// s() -> 1, 0xff, 0x6162000000000000000000000000000000000000000000000000000000000000, 15
|
||||||
|
// g(uint16[]): 0x20, 3, 1, 2, 3 -> 0x20, 3, 1, 2, 3
|
||||||
|
// gas irOptimized: 113144
|
||||||
|
// gas legacy: 114806
|
||||||
|
// gas legacyOptimized: 113085
|
||||||
|
// small(uint256): 0 -> 1
|
||||||
|
// small(uint256): 1 -> 2
|
||||||
|
// h(bytes2[]): 0x20, 3, "ab", "cd", "ef" -> 0x20, 3, "ab", "cd", "ef"
|
||||||
|
// gas irOptimized: 113317
|
||||||
|
// gas legacy: 114496
|
||||||
|
// gas legacyOptimized: 113214
|
||||||
|
// l(uint256): 0 -> 0x6162000000000000000000000000000000000000000000000000000000000000
|
||||||
|
// l(uint256): 1 -> 0x6364000000000000000000000000000000000000000000000000000000000000
|
Loading…
Reference in New Issue
Block a user