Skip to content

Commit 483f07c

Browse files
Add a virtual destructor to cprover_exception_baset
While exceptions under normal usage scenarios don't need a virtual destructor (when an exception is thrown, it is the runtimes responsibility to properly destroy it, and it does know the type of the exception at the point where it's thrown), it is just generally good practice to have virtual destructors in base classes to accomodate for situations where a polymorphic destruction may be needed.
1 parent 49230ec commit 483f07c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/util/exception_utils.h

+5
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,18 @@ Author: Fotis Koutoulakis, [email protected]
1616
/// Base class for exceptions thrown in the cprover project.
1717
/// Intended to be used as a convenient way to have a
1818
/// "catch all and report errors" from application entry points.
19+
/// Note that the reason we use a custom base class as opposed to
20+
/// std::exception or one of its derivates to avoid them being accidentally
21+
/// caught by code expecting standard exceptions to be only thrown by the
22+
/// standard library.
1923
class cprover_exception_baset
2024
{
2125
public:
2226
/// A human readable description of what went wrong.
2327
/// For readability, implementors should not add a leading
2428
/// or trailing newline to this description.
2529
virtual std::string what() const = 0;
30+
virtual ~cprover_exception_baset() = default;
2631
};
2732

2833
/// Thrown when users pass incorrect command line arguments,

0 commit comments

Comments
 (0)