Manipulating multi-dimensional arrays causes IR-based code generation to return incorrect values.
- Dominant language
- C++
- Stars
- 25.7k
- Forks
- 6.2k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 29
Description
## 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
```solidity
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"
}
```
Contributor guide
Research direction
Reproduce the contract in Remix with Solidity 0.8.28, comparing IR-based and Legacy code generation for the multi-dimensional array returned by manipulateData. Trace how the assembly mstore operations in set affect the array, then verify that both code-generation paths return identical contents, not just matching lengths.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, solidity
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100