[Bug c++/115410] Missing optimization: typeid(*a)==typeid(*b) could be optimized to a->_vptr==b->_vptr
user202729 at protonmail dot com
gcc-bugzilla@gcc.gnu.org
Mon Jun 10 06:51:46 GMT 2024
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115410
--- Comment #7 from user202729 <user202729 at protonmail dot com> ---
(In reply to Andrew Pinski from comment #6)
> They can be different due to the way shared libraries work.
Ah, too bad.
Is it safe to at least assume that the function pointers inside the virtual
pointer table be equal then? The original motivation was to devirtualize the
function call inside something like (though this would be a different PR)
if(typeid(*x)==typeid(A))
x->f();
then would it be safe to assume `x->_vptr[0] == &A::f`?
More information about the Gcc-bugs
mailing list