/vd (Disable Construction Displacements)
Collapse the table of content
Expand the table of content
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

/vd (Disable Construction Displacements)

/vd supports incorrect behavior in an early version of Visual C++, and is no longer needed.



Suppresses the vtordisp constructor/destructor displacement member. Choose this option only if you are certain that all class constructors and destructors call virtual functions virtually.


Enables the creation of hidden vtordisp constructor/destructor displacement members. This choice is the default.


Allows you to use dynamic_cast Operator on an object being constructed. For example, a dynamic_cast from a virtual base class to a derived class.

/vd2 adds a vtordisp field when you have a virtual base with virtual functions. /vd1 should be sufficient. The most common case where /vd2 is necessary is when the only virtual function in your virtual base is a destructor.

These options apply only to C++ code that uses virtual bases.

Visual C++ implements C++ construction displacement support in situations where virtual inheritance is used. Construction displacements solve the problem created when a virtual function, declared in a virtual base and overridden in a derived class, is called from a constructor during construction of a further derived class.

The problem is that the virtual function may be passed an incorrect this pointer as a result of discrepancies between the displacements to the virtual bases of a class and the displacements to its derived classes. The solution provides a single construction displacement adjustment, called a vtordisp field, for each virtual base of a class.

By default, vtordisp fields are introduced whenever the code defines user-defined constructors and destructors and also overrides virtual functions of virtual bases.

These options affect entire source files. Use vtordisp to suppress and then re-enable vtordisp fields on a class-by-class basis.

To set this compiler option in the Visual Studio development environment

  1. Open the project's Property Pages dialog box. For details, see How to: Open Project Property Pages.

  2. Click the C/C++ folder.

  3. Click the Command Line property page.

  4. Type the compiler option in the Additional Options box.

To set this compiler option programmatically

© 2016 Microsoft