https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110057
Jason Merrill <jason at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jason at gcc dot gnu.org, | |jwakely.gcc at gmail dot com --- Comment #12 from Jason Merrill <jason at gcc dot gnu.org> --- (In reply to user202729 from comment #11) > if (__builtin_vptr(this->_M_impl._M_finish) != __builtin_vptr(_Tp)) > __builtin_unreachable(); This is more or less what the existing speculative devirtualization code (ipa-devirt.cc) does. It might be nice to be able to force speculative devirtualization in some circumstances, perhaps in the destroy_at function. But for vector specifically, and probably other containers as well, we know specifically the type that we're destroying, so the library should use a scoped destructor call (i.e. ptr->_Tp::~_Tp()) to force a non-virtual call. So the vector situation seems to me like a library issue.