Closed xermicus closed 8 months ago
Found a case where Solang (latest commit on main) generates invalid code, failing an LLVM assertion. Code is from here but I extracted a minimal reproducer below which is enough to trigger the bug.
main
$ solang compile --target polkadot --release reproducer.sol thread 'main' panicked at /home/glow/.cargo/registry/src/index.crates.io-6f17d22bba15001f/inkwell-0.2.0/src/values/enums.rs:286:13: Found PointerValue(PointerValue { ptr_value: Value { name: "struct member14", address: 0x5c58cccf2980, is_const: false, is_null: false, is_undef: false, llvm_value: " %\"struct member14\" = getelementptr inbounds { ptr, i256, i256, i256 }, ptr %0, i32 0, i32 3", llvm_type: "ptr" } }) but expected the IntValue variant
contract Bug { struct State { bytes input; uint256 incnt; uint256 bitbuf; uint256 bitcnt; } function bits(State memory s) public pure { uint256 val = s.bitbuf; while (s.bitcnt < 1) { val |= uint256(uint8(s.input[s.incnt++])) << s.bitcnt; } s.bitbuf = val >> 1; } }
I submitted a PR to fix this issue, looking forward to your review. 😄
@yp945 thanks for the fix
Found a case where Solang (latest commit on
main
) generates invalid code, failing an LLVM assertion. Code is from here but I extracted a minimal reproducer below which is enough to trigger the bug.Minimal reproducer