CPP Support
Supported features:
ESBMC v7 supports the following C++ features:
Class
C++ New and Delete: Dangling pointer, Double delete and Mismatched operators
constructors and destructors
lvalue reference
rvalue reference
Move semantics: Move constructor, Move assignment operator.
C++ OM fixed: string_view, algorithm, vector, Typeinfo, iterator, string, queue, numeric, set
Standard lib: <type_traits>
Improved references and Temporary object
New Clang node
- DefaultInit Expr
- sizeof Expr
- C++ 11 nullptr_t Expr
- C++ 17 variable template declarations
template
- Umbrella issue: https://github.com/esbmc/esbmc/issues/989 (original estimate 2-3 weeks, logged 2.5 weeks)
inheritance and polymorphism:
- single-level polymorhism
- multi-level polymorhism
- pure virtual method
- virtual inheritance (the diamond problem)
- correct order of ctors/dtors:
- tracked by the umbrella issue issue 940, affected features are listed below:
- Virtual destructor
- Base initialization for the most-derivied class
- Order of destruction in case of object composition (part-whole relationship)
- tracked by the umbrella issue issue 940, affected features are listed below:
(TODO) Exception handling:
- try-catch, throw
Features WIP:
- Fixing our OMs for STL libraries
- See guidelines: https://github.com/esbmc/esbmc/wiki/Guidelines-for-Fixing-Operational-Models-(OM)-in-ESBMC
- OM workload estimate and tracking: https://github.com/esbmc/esbmc/wiki/OM-Workload-Estimate-and-Tracking
Backlog:
Issues are listed from high to low priority in each subsection:
Feature issues:
- [] [Order of ctor/dtor - umbrella issue] https://github.com/esbmc/esbmc/issues/940
-
[dangling pointer] https://github.com/esbmc/esbmc/issues/894 -
[zero initialization] https://github.com/esbmc/esbmc/issues/1103 - [Corner cases]:
- [] [vtable setup for class template] https://github.com/esbmc/esbmc/issues/1127
-
[unamed union ctor] https://github.com/esbmc/esbmc/issues/1128 - [] [function as non-type parameter] https://github.com/esbmc/esbmc/issues/1129
-
[formalisation dynamic alloc] https://github.com/esbmc/esbmc/issues/825 -
[new] https://github.com/esbmc/esbmc/issues/924
OM issues:
- [OM simplification] https://github.com/esbmc/esbmc/issues/965
Development Tracking:
The new clang-based frontend is under development. We are currently working to pass the benchmark regression/esbmc-cpp/cpp which contains 370 test cases. Please see benchmark stats in each subsection.
The stats are generated by applying the following commands in the benchmark logs from Github workflow “Run a Benchmark”:
To generate stats about error signatures:
egrep "Assertion|ERROR" * -rn | egrep -v "//" | cut -d':' -f3- | sort | uniq -cTo generate stats about passes:
egrep "VERIFICATION FAILED|VERIFICATION SUCCESSFUL" * -rn | rev | cut -d ':' -f 1 | rev | sort | uniq -cSummary of Pass Rate in Each Test Suite:
| Test Suite | Pass Rate | Date | Remarks |
|---|---|---|---|
cpp | 333/376, 88.56% | 24/06/2024 | Last run: result link |
inheritance_bringup | 14/15, 93.3% | 24/06/2024 | Skipped as the last TC is not passable even by the old esbmc-v2.1 |
polymorphism_bringup | 39/45, 86.7% | 24/06/2024 | 1x TC failure is caused by issue 938. 2x TC failures are caused by issue 940. The remaining failures are skipped as they are not passable even by the old esbmc-v2.1 |
cbmc | 119/120, 99% | 24/06/2024 | This suite contains ‘Template_XXX’ TCs only. Last run: result link The failed TC is covered by https://github.com/esbmc/esbmc/issues/940 |
gcc-template-tests | 26/32, 81.25% | 24/06/2024 | Last run: result link - apart from arg6, const1, spec26, union1 and vtable1, the remaining failed TCs are not passable by v2.1 |
template | 17/27, 62.96% | 24/06/2024 | Last run: result link - the remaining failed TCs are either OM dependent or not passable by v2.1 |
stream | 57/65, 86.15% | 24/06/2024 | Last run: result link |
string | 206/233, 88% | 24/06/2024 | Last run: result link |
algorithm | 135/168, 80% | 24/06/2024 | Last run: result link |
deque | 38/43, 88% | 24/06/2024 | Last run: result link |
list | 47/72, 65% | 24/06/2024 | Last run: result link |
map | 38/47, 81% | 24/06/2024 | Last run: result link |
multimap | 41/45, 91% | 24/06/2024 | Last run: result link |
multiset | 8/43, 18% | 24/06/2024 | Last run: result link |
priority_queue | 13/15, 87% | 24/06/2024 | Last run: result link |
set | 30/48, 62% | 24/06/2024 | Last run: result link |
stack | 12/14, 85% | 24/06/2024 | Last run: result link |
vector | 133/149, 89% | 24/06/2024 | Last run: result link |
try_catch | 73/83, 88% | 24/06/2024 | Last run: result link |
The following lines are used to fix the TCs, and added here for future reference: The commands below are for future reference: Fix the include path for Linux CIs:
egrep "\-I ~/libraries" . -rl | xargs sed -i 's/-I \~\/libraries/-I \/__w\/esbmc\/esbmc\/src\/cpp\/library/g'Add tag for each TC in a test suite:
from pathlib import Path
for path in Path('./').rglob('test.desc'):
print(path)
f = open(path,'r')
lines = f.readlines()[:-1]
lines.append("<item_10_mode>KNOWNBUG</item_10_mode>" + "\n")
lines.append("</test-case>")
f.close()
f = open(path,'w')
f.writelines(lines)Tracking Error Signatures for esbmc-cpp/cpp test suite:
Since we’ve added the support for most of the key features, most, if not all, errors are of the type PARSE ERRORS in our OMs for STL test suites. There’s no need to track parse errors for those test suites. See section Summary of Pass Rate in Each Test Suite for the most up-to-date pass rate.
Build LLVM from source:
Using a debug build of clang greatly helps debugging the clang-based C++ converter in ESBMC. See Rafael’s guide in https://github.com/esbmc/esbmc/wiki/Windows-Build#llvm