You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p>This rule finds calls to pure virtual member functions in constructors and destructors. Such calls do not perform virtual dispatch, and can cause undefined behavior.</p>
9
+
10
+
</overview>
11
+
<recommendation>
12
+
<p>Do not rely on virtual dispatch in constructors and destructors. Instead, each class should be responsible for acquiring and releasing its resources.</p>
13
+
14
+
</recommendation>
15
+
<example><samplesrc="UnsafeUseOfThis.cpp" />
16
+
17
+
18
+
19
+
</example>
20
+
<references>
21
+
22
+
<li>
23
+
<ahref="https://isocpp.org/wiki/faq/strange-inheritance#calling-virtuals-from-ctors">When my base class’s constructor calls a virtual function on its this object, why doesn’t my derived class’s override of that virtual function get invoked?</a>
24
+
</li>
25
+
<li>
26
+
<ahref="https://wiki.sei.cmu.edu/confluence/display/cplusplus/OOP50-CPP.+Do+not+invoke+virtual+functions+from+constructors+or+destructors">OOP50-CPP. Do not invoke virtual functions from constructors or destructors</a>
27
+
</li>
28
+
<li>
29
+
<ahref="https://scc.ustc.edu.cn/zlsc/sugon/intel/ssadiag_docs/pt_reference/references/sc_cpp_virtual_call_in_ctor.htm">Virtual function call in constructor</a>
0 commit comments