http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58678
--- Comment #17 from Jason Merrill <jason at gcc dot gnu.org> --- (In reply to Markus Trippelsdorf from comment #0) > class A { > public: > virtual ~A(); > }; > class B : A { > virtual int m_fn1(); > }; > void fn1() { > delete reinterpret_cast<B*>(1); > } I don't understand how this could be devirtualized, since there is no actual B object. But this is beside the point. In general I agree with you: there's a fundamental problem here with devirtualization knowing which function to call vs. that function being hidden in another DSO. Client code has no way to know whether the library was built with -fvisibility=hidden. I think we want to add a GCC flag to force more conservative assumptions about visibility, i.e. that we can't refer to anything that might not be defined in the current object, and KDE programs could use that flag. Perhaps we should even make it the default in non-LTO mode.