Skip to content

[ICE]: Shift-left overflow #1781

@Subway2023

Description

@Subway2023

Version: v0.3.3: v0.3.3-70-g32a45ea1
Description: uint256 shifted = (a << shifts[0]) << shifts[1]; causes an overflow, and the subsequent return shifted; triggers a runtime error.

contract C {
    function shiftBugExample() public pure returns (uint256) {
        uint256 a = 1;
        uint256[] memory shifts = new uint256[](2);
        shifts[0] = 256;
        shifts[1] = 1;
        uint256 shifted = (a << shifts[0]) << shifts[1]; // Total shift size is 2**256 + 1
        return shifted; // This should account the overflow, but due to the bug it may not.
    }
}
thread 'main' panicked at 'Found PointerValue(PointerValue { ptr_value: Value { name: "index_access43", address: 0x5f1e4114f1e0, is_const: false, is_null: false, is_undef: false, llvm_value: "  %index_access43 = getelementptr i8, ptr %data42, i32 0", llvm_type: "ptr" } }) but expected the IntValue variant', /github/home/.cargo/registry/src/index.crates.io-6f17d22bba15001f/inkwell-0.2.0/src/values/enums.rs:286:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions