solidity
solidity copied to clipboard
IR-based Codegen fails to generate bin at version of 0820
Description
When I want to reproduce this bug AbiReencodingHeadOverflowWithStaticArrayCleanup, I find that IR-based Codegen fails to generate bin under version of 0821. However, if I use solc-0821, IR-based Codegen success.
Environment
- Compiler version: 0.8.20
- Target EVM version (as per compiler settings): No restrictions
- Framework/IDE (e.g. Truffle or Remix): Command-line
- EVM execution environment / backend / blockchain client: None
- Operating system: Linux
Steps to Reproduce
contract Bug {
function f(uint[2] calldata b) pure public returns (bytes memory){
return abi.encode("aaaa", b);
}
}
contract Executor {
function run() external returns(string memory){
Bug bug = new Bug();
bytes memory r = bug.f([uint(1), 2]);
(string memory a, uint[2] memory b) = abi.decode(r, (string, uint[2]));
return a;
}
}
solc-0820 --via-ir --bin-runtime test.sol
If I remove --bin-runtime, test.sol can be compiled successfully.
EmptyByteArrayCopy also have the problem
contract C {
bytes data;
function f() public returns (bytes memory) {
// Empty byte array
bytes memory t;
// Store something else in memory after it
uint[2] memory x;
x[0] = type(uint).max;
// Copy the empty byte array to storage,
// this will copy too much from memory.
data = t;
// Create a new byte array element,
// this will only update the length value.
data.push();
// Now, `data[0]` is `0xff` instead of `0`.
return data;
}
}