solang icon indicating copy to clipboard operation
solang copied to clipboard

Undefined index access succeeded.

Open Subway2023 opened this issue 11 months ago • 0 comments

Version: v0.3.3: Atlantis Description: The array arr is not initialized, yet when accessing arr[1], the program executes successfully. However, if this code is run in solc+EVM, it will throw an error.

contract c {
    bytes arr;
    function f() public { bytes1 a = arr[1];}
}

Reproduction: I set up a Solang compilation and execution environment to test the program.

solang/target/debug/vmRunNoPara test.sol c f

The program executes normally.

Contract name: c
function new for 7QL9j5bBcStG2Nx2nx4m7br2HerAAwkxSaJK1RWch2QS
input: 872ccdc6190148bc
running bpf with calldata:872ccdc6190148bc
program: 7QL9j5bBcStG2Nx2nx4m7br2HerAAwkxSaJK1RWch2QS
static: length:8 0000000000000000
offset:28 prev:10 next:10 length:0 allocated:0 
function f for 7QL9j5bBcStG2Nx2nx4m7br2HerAAwkxSaJK1RWch2QS
input: 352dd00eb9a6751b
running bpf with calldata:352dd00eb9a6751b
program: 7QL9j5bBcStG2Nx2nx4m7br2HerAAwkxSaJK1RWch2QS
sol_set_return_data: 
static: length:8 0000000000000000
offset:28 prev:10 next:1

Execute in remix

Image

Subway2023 avatar Feb 10 '25 05:02 Subway2023