Miscellaneous-NoVirtualDestructor¶
Class needs a virtual destructor if at least one member function is virtual
Required inputs: IR
If an object is deleted through a pointer to a base class and that base class does not have a virtual destructor, undefined behavior occurs.
Example
class C {
C() {} // explicit constructor, may take arguments
C(const C&) = delete;
C& operator=(const C&) = delete;
virtual ~C() { }
};
Note that the GeneralPurpose-RuleOfThree requires that you
also declare copy constructor
and copy assignment operators when declaring a virtual destructor.
You should declare these as deleted if the class is not supposed to be copyable.Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
missing_virtual_destructor |
Class needs a virtual destructor. |
None |
False |
Options¶
This rule shares the following common options: exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
accept_none_destructor¶
accept_none_destructor : bool = True