Skip to content

Asserting conditions over uninitialized variables #7997

Open
@salvadorer

Description

@salvadorer

Dear all,
looking at the following program, I am asking myself why CBMC does not report the assertion failure:

#include <assert.h>

extern void __VERIFIER_assume(int cond);
extern int __VERIFIER_nondet_int(void);

int main(void) {
  if (__VERIFIER_nondet_int())
    goto switch_2_1;
  int tmp_ndt_4 = __VERIFIER_nondet_int();
  __VERIFIER_assume(__VERIFIER_nondet_int());
  __VERIFIER_assume (tmp_ndt_4 == 1);
  switch_2_1:
    assert(tmp_ndt_4 > 0);
  return 0;
}

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

Metadata

Metadata

Labels

awsBugs or features of importance to AWS CBMC usersaws-highbug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions