Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solang panic at bitvec package #1702

Open
lum7na opened this issue Jan 21, 2025 · 0 comments
Open

Solang panic at bitvec package #1702

lum7na opened this issue Jan 21, 2025 · 0 comments

Comments

@lum7na
Copy link

lum7na commented Jan 21, 2025

Compile: solang compile a.sol --target solana

contract Test {
  function h(int256 a, int256 b) private returns(int256) {
    return (a + (b / 2)) / b;
  }

  function g(int256 a, int256 b, int256 c) private returns(int) {
    return 1;
  }

  function f(int256 a, int256 b, int256 c) private returns(int256) {
    return (a << 12) | (b << 7) | c;
  }

  int256 constant A = type(int256).max;

  int256 constant B = 1000;

  function test(int256 a, int256 b) public returns(bool) {
    int256 c = g(h(b, B), b, a) & A;
    int256 d = b & A;
    if (A > 0) {
      assert(((c / d) + (c & a) * d) == ((8 / 2) + (4 & 3) * 1));
      c = 1;
      if ((c & int256(1 << (uint256(A) - 1))) != 0) {
        c |= int256(~((1 << uint256(A)) - 1));
      }
    }
    return (f(B, B, a) > B) || (d > B);
  }
}

Output:

thread 'main' panicked at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bitvec-1.0.1/src/slice/api.rs:2681:1:
range 510..256 out of bounds: 256
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Solang version: solang version v0.3.3-56-g08dbe495

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant