[Interest] qobject_cast

Thiago Macieira thiago.macieira at intel.com
Thu Apr 20 18:53:34 CEST 2017

On quinta-feira, 20 de abril de 2017 09:35:15 PDT Igor Mironchik wrote:
> Hi,
> >> QObject has virtual destructor... dynamic_cast will work. But it doesn't
> >> matter, the problem was in another...
> > 
> > If your class has virtual functions or derives from such base class, and
> > have inline (or default) virtual destructor,its  v-table will be emitted
> > in each translation unit. This is undesirable and can lead to subtle
> > problems. See e.g.
> > 
> > http://llvm.org/docs/CodingStandards.html#provide-a-virtual-method-anchor-> > for-classes-in-headers
> There said that it can lead just to increasing objects size in linking
> time. What problems may appear?

Emitting in multiple places is not usually a problem.

The problem happens when DLL/shared library boundaries appear. Depending on 
your compilation flags, the symbols will not be merged at runtime and ODR 
violations will occur.

I've said this before. A plugin system consists of:
 a) zero or more plugins
 b) zero or more applications
 c) exactly one DLL/shared library

Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel Open Source Technology Center

More information about the Interest mailing list