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

Semantics of assert statements #8223

Open
salvadorer opened this issue Feb 27, 2024 · 2 comments
Open

Semantics of assert statements #8223

salvadorer opened this issue Feb 27, 2024 · 2 comments

Comments

@salvadorer
Copy link

Hey,
I'm working with CBMC 5.95.1 and I noticed that CBMC does not add asserted conditions to the path conditions. For e.g.:

#include <assert.h>

extern int __VERIFIER_nondet_int(void);

int main() {
  int x = __VERIFIER_nondet_int();
  assert(x < 0);
  assert(x <= 0);
 }

CBMC would report a warning about both assertions but there's actually no value for x that can trigger the second assertion.

@tautschnig
Copy link
Collaborator

That's indeed true, see #5866: we might revisit this at some point, but until then please redefine the assert macro like this:

#undef assert
#define assert(C) __CPROVER_assert((C), "assertion"); __CPROVER_assume(C)

@martin-cs
Copy link
Collaborator

@salvadorer Just for interest, this is why they don't alter the path condition:

#2031
92b92d6

I'm still reasonably convinced this is the correct design decision.

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

3 participants