Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IR-based Codegen fails to generate bin at version of 0820 #15044

Open
Subway2023 opened this issue Apr 21, 2024 · 1 comment
Open

IR-based Codegen fails to generate bin at version of 0820 #15044

Subway2023 opened this issue Apr 21, 2024 · 1 comment
Labels

Comments

@Subway2023
Copy link

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

image

If I remove --bin-runtime, test.sol can be compiled successfully.

@Subway2023
Copy link
Author

Subway2023 commented Apr 24, 2024

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;
    }
}

1713929797232

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant