This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
[C++] Optimizing dynamic_cast to a final C++ class
- From: Florian Weimer <fweimer at redhat dot com>
- To: GCC <gcc at gcc dot gnu dot org>
- Date: Tue, 05 Nov 2013 13:36:53 +0100
- Subject: [C++] Optimizing dynamic_cast to a final C++ class
- Authentication-results: sourceware.org; auth=none
I've looked at optimizing dynamic_cast to final C++ class. In theory,
it should be possible to load the vtable pointer, compare it to the
expected value, and use the original pointer if it matches, or NULL
otherwise (for pointers, references are similar but need the conditional
throw).
But I remember a discussion on the cxxabi list that vtables are not
deduplicated if they are contained in multiple libraries, so a simple
pointer comparison won't do. Is there anything else that could be used
as a reliable marker? If not, do you think it would be feasible to add
a fast-path for final target classes to the __dynamic_cast implementation?
--
Florian Weimer / Red Hat Product Security Team