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

Internal compiler error when using --model-checker-show-proved-safe option in SMTChecker #15113

Open
pgebal opened this issue May 16, 2024 · 0 comments
Assignees
Projects

Comments

@pgebal
Copy link
Collaborator

pgebal commented May 16, 2024

Version affected: commit f9c8ab0
To replicate run solc --model-checker-engine all --model-checker-targets all --model-checker-show-proved-safe A.sol

A.sol:

// SPDX-License-Identifier: GPL-3.0

pragma solidity >=0.0.0;
type I16 is int16;
using {
    bitor as |, bitand as &, bitxor as ^, bitnot as ~,
    add as +, sub as -, unsub as -, mul as *, div as /, mod as %,
    eq as ==, noteq as !=, lt as <, gt as >, leq as <=, geq as >=
} for I16 global;

function bitor(I16 x, I16 y) pure returns (I16) { return I16.wrap(I16.unwrap(x) | I16.unwrap(y)); }
function bitand(I16 x, I16 y) pure returns (I16) { return I16.wrap(I16.unwrap(x) & I16.unwrap(y)); }
function bitxor(I16 x, I16 y) pure returns (I16) { return I16.wrap(I16.unwrap(x) ^ I16.unwrap(y)); }
function bitnot(I16 x) pure returns (I16) { return I16.wrap(~I16.unwrap(x)); }

function add(I16 x, I16 y) pure returns (I16) { return I16.wrap(I16.unwrap(x) + I16.unwrap(y)); }
function sub(I16 x, I16 y) pure returns (I16) { return I16.wrap(I16.unwrap(x) - I16.unwrap(y)); }
function unsub(I16 x) pure returns (I16) { return I16.wrap(-I16.unwrap(x)); }
function mul(I16 x, I16 y) pure returns (I16) { return I16.wrap(I16.unwrap(x) * I16.unwrap(y)); }
function div(I16 x, I16 y) pure returns (I16) { return I16.wrap(I16.unwrap(x) / I16.unwrap(y)); }
function mod(I16 x, I16 y) pure returns (I16) { return I16.wrap(I16.unwrap(x) % I16.unwrap(y)); }

function eq(I16 x, I16 y) pure returns (bool) { return I16.unwrap(x) == I16.unwrap(y); }
function noteq(I16 x, I16 y) pure returns (bool) { return I16.unwrap(x) != I16.unwrap(y); }
function lt(I16 x, I16 y) pure returns (bool) { return I16.unwrap(x) < I16.unwrap(y); }
function gt(I16 x, I16 y) pure returns (bool) { return I16.unwrap(x) > I16.unwrap(y); }
function leq(I16 x, I16 y) pure returns (bool) { return I16.unwrap(x) <= I16.unwrap(y); }
function geq(I16 x, I16 y) pure returns (bool) { return I16.unwrap(x) >= I16.unwrap(y); }

contract C {
    I16 constant MINUS_TWO = I16.wrap(-2);
    I16 constant ZERO = I16.wrap(0);
    I16 constant ONE = I16.wrap(1);
    I16 constant TWO = I16.wrap(2);
    I16 constant THREE = I16.wrap(3);
    I16 constant FOUR = I16.wrap(4);

    function testBitwise() public pure {
        assert(ONE | TWO == THREE);
        assert(ONE & THREE == ONE);
        assert(TWO ^ TWO == ZERO);
        assert(~ONE == MINUS_TWO);
    }

    function testArithmetic() public pure {
        assert(TWO + TWO == FOUR);
        assert(TWO - TWO == ZERO);
        assert(-TWO == MINUS_TWO);
        assert(TWO * TWO == FOUR);
        assert(TWO / TWO == ONE);
        assert(TWO % TWO == ZERO);
    }

    function testComparison() public pure {
        assert(TWO == TWO);
        assert(!(TWO != TWO));
        assert(!(TWO < TWO));
        assert(!(TWO > TWO));
        assert(TWO <= TWO);
        assert(TWO >= TWO);
    }
}
@pgebal pgebal self-assigned this May 16, 2024
@pgebal pgebal added this to To Do in SMT Checker via automation May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: To Do
SMT Checker
  
To Do
Development

No branches or pull requests

1 participant