-
Notifications
You must be signed in to change notification settings - Fork 273
Asserting conditions over uninitialized variables #7997
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
Comments
From a cursory reading of your program, your Your |
For the branch in which the condition in the if is evaluated to |
Hi, I tested your program and I can say that the behaviour you experimented is a current bug of CBMC. Here's a simplified version of your program: #include <assert.h>
extern void __VERIFIER_assume(int cond);
extern int __VERIFIER_nondet_int(void);
int main(void) {
int if_condition = __VERIFIER_nondet_int();
if (if_condition) {
goto label;
}
int var = __VERIFIER_nondet_int();
__VERIFIER_assume (var == 1);
label:
assert(var > 0);
return 0;
} Running CBMC should return verification failure and the trace to obtain this is by having For some reason it seems that the simplification step of CBMC adds a non-guarded (by the if For the moment it is possible to get the expected |
Actually it seems to be a problem also when removing the #include <assert.h>
extern void __VERIFIER_assume(int cond);
extern int __VERIFIER_nondet_int(void);
int main(void) {
int if_condition = __VERIFIER_nondet_int();
if (if_condition) {
goto label;
}
int var = 1;
label:
assert(var > 0);
return 0;
} Also in this case the variable This happens irregardless of |
We might have to move all declarations (not the initialisations!) to the beginning of a block while producing the GOTO program. |
I agree as:
Still it has to be investigated why in the original program the simplifier adds an unguarded |
Dear all,
looking at the following program, I am asking myself why CBMC does not report the assertion failure:
I know that jumping over a variable declaration and reading the variable can give any value, so I thought the assertion should fail.
The observed behavior is especially surprising since changing the first assumption to __VERIFIER_assume(0) would give the warning about the assertion as expected.
Calling "cbmc test.c" gives:
** Results:
test.c function main
[main.assertion.1] line 13 assertion tmp_ndt_4 > 0: SUCCESS
** 0 of 1 failed (1 iterations)
VERIFICATION SUCCESSFUL
CBMC version: 5.95.0
Operating system: Ubuntu
The text was updated successfully, but these errors were encountered: