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

Confusion of single-bits values and booleans for C type _Bool #89

Open
gernst opened this issue Oct 12, 2021 · 0 comments
Open

Confusion of single-bits values and booleans for C type _Bool #89

gernst opened this issue Oct 12, 2021 · 0 comments

Comments

@gernst
Copy link

gernst commented Oct 12, 2021

The following program trips up handling of single-bit values vs booleans in the backend, such a single-bit value can be passed either as test to _sym_build_bool_to_bits or as constraint _sym_push_path_constraint, instead of a proper boolean value.

It is clearly related to type _Bool (which is part of the C standard, from stdbool.h), replacing _Bool by an integer type solves the problem.

_Bool __VERIFIER_nondet_bool() {
    char x = 0;
    read_symbolized(0, &x, sizeof(x));
    _Bool y = x >=0;
    return y;
}

int main() {
    _Bool x = __VERIFIER_nondet_bool();

    if(x) return 0;
    else return 1;
}

This effectively leads to a type error, e.g., in the simple backend:

Sort mismatch at argument #1 for function (declare-fun ite (Bool (_ BitVec 8) (_ BitVec 8)) (_ BitVec 8)) supplied sort is (_ BitVec 1)
simple: /home/ernst/tools/symcc/runtime/simple_backend/Runtime.cpp:78: void {anonymous}::handle_z3_error(Z3_context, Z3_error_code): Assertion `!"Z3 error"' failed.
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