Skip to content

Commit 2db30c0

Browse files
Add an explanatory hook with example to the README
1 parent 6728798 commit 2db30c0

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,25 @@ The primary focus of this project is to validate a reasonable subset of C++ cont
1818
with assertions, and to support [C++26](https://en.cppreference.com/w/cpp/language/contracts.html)
1919
as these first class contracts are supported by compilers.
2020

21+
```cpp
22+
void f(int x) {
23+
/*@ requires @*/
24+
assert(x > 0);
25+
}
26+
27+
void g() {
28+
f(0); // contract violation
29+
}
30+
```
31+
32+
Contract violations are discovered through a combination of CodeQL range analysis and SMT constraint generation that is then solved by Z3.
33+
34+
We currently support the following types of assertions:
35+
- `assert` macros that have been annotated `/*@ requires @*/`.
36+
- `BSLS_ASSERT` from [BDE](https://bloomberg.github.io/bde/).
37+
38+
In the future, we hope to support C++26 contract specifiers `pre(...)` and `post(...)`.
39+
2140
This project also serves as a useful example that may benefit other languages, and the availability
2241
of Z3 inside CodeQL queries may have other useful applications that may deserve to be integrated
2342
into this project in the future.

0 commit comments

Comments
 (0)