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

Manipulating multi-dimensional arrays causes IR-based code generation to return incorrect values. #15602

Open
Subway2023 opened this issue Dec 2, 2024 · 0 comments
Labels

Comments

@Subway2023
Copy link

Description

Using assembly statements to manipulate multi-dimensional arrays results in inconsistencies between IR-based code generation and Legacy code generation. However, the length format of the results is consistent; only some of the content differs.

Environment

  • Compiler version: 0.8.28
  • Target EVM version (as per compiler settings): None
  • Framework/IDE (e.g. Truffle or Remix): Remix
  • EVM execution environment / backend / blockchain client: None
  • Operating system: None

Steps to Reproduce

contract BuggyTest {
    uint24[3][][4] data;
    function set(uint24[3][][4] memory x) private returns (uint24[3][][4] memory) {
        assembly {
            mstore(add(x, mul(96, 3)), 1) // potentially faulty manipulation of index 
            mstore(add(x, mul(96, 4)), 7) // potentially faulty manipulation of index
        }
        return x;
    }
    function manipulateData() public returns (uint24[3][] memory) {
        while (data[1].length < 4) data[1].push();
        return set(data)[1];
    }
}

IR-based codegen

decoded output from remix

{
	"0": "uint24[3][]: 0,0,7,0,0,0,0,0,0,768,0,262144"
}

Legacy codegen

decoded output from remix

{
	"0": "uint24[3][]: 0,0,7,0,0,0,0,0,0,256,0,262144"
}
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

2 participants
@Subway2023 and others