https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66223
--- Comment #9 from Jakub Jelinek <jakub at gcc dot gnu.org> --- I think it is a bad idea to pessimize code just because it might be invoking undefined behavior. I'd really do this only if the user asked for that, and IMHO such a switch is flag_sanitize & SANITIZE_UNREACHABLE (or we could add -fsanitize=pure-virtual, part of -fsanitize=undefined), which would just disable such optimizations (i.e. unless proven pure virtual might not be called, don't remove it from the candidates).