Skip to content

CBMC reporting incosistently assertion failures #8196

Closed
@salvadorer

Description

@salvadorer

Hi,
I notice that if I invoke cbmc without any arguments on the following code I see a warning about the assertion:

#include <assert.h>
extern void __VERIFIER_assume(int cond);
extern int __VERIFIER_nondet_int(void);
int main() {
  int N;
  if (__VERIFIER_nondet_int()) {
    N = 5;
  } else {
    N = 6;
    __VERIFIER_assume(0);
  }
  int arr[N];
  int j = 5;
  arr[j] = 5;
  assert(arr[j] == 5);
  return 0;
}

Result:
[main.assertion.1] line 15 assertion arr[j] == 5: FAILURE

I know that arr[j] is out-of bounds. Still the behavior is surprising since dropping the assumption results in 0 warnings even tough the array access might also be out of bounds in this case.

CBMC version: 5.95.1
Operating system: Ubuntu 22.04.3
Exact command line resulting in the issue: cbmc test.c

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions