When solc creates code for arrays when they are declared public
. In particular, it contains a check on the length of the array. For example, this:
contract OutOfBoundsException {
uint256[8] public array;
}
compiled with solc --optimize
produces:
...
tag_3:
pop
/* "contracts/oobtest.sol":46:68 uint256[8] public array */
tag_4
calldataload(0x4)
jump(tag_5)
tag_4:
# dead code
tag_5:
0x0
dup1
sload
dup3
swap1
dup2
lt
tag_6
jumpi
invalid
tag6
# ...
The --optimize
flag was used to remove some of the crud and simplify some of the above.
What is going on in the basic block that starts tag_5
and why is it needed?