Home / Vulnerability Database / C or C++ : Calling a virtual function from a constructor or destructor
C/C++

C or C++ : Calling a virtual function from a constructor or destructor

Overview

Call to virtual function during construction/destruction will not dispatch to derived class.

In C++ the Base class will build its version of the virtual methods prior to entering its own construction. At this point a call to the virtual method will end up calling the Base version of the method or producing a pure virtual method called in case it has no implementation at that level of the hierarchy. After the Base has been fully constructed, the compiler will start building the Derived class, and it will override the method pointers to point to the implementations in the next level of the hierarchy.

MEDIUM

DerScanner Severity Score

Do you want to fix C or C++ : Calling a virtual function from a constructor or destructor in your application?

See also

C/C++

C or C++ : Dead store

C/C++

C or C++ : Use after free

C/C++

C or C++ : va_list uninitialized