https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98103
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-10 branch has been updated by Marek Polacek <mpola...@gcc.gnu.org>: https://gcc.gnu.org/g:a38b0c6d62d90a5a30cbd00d32e7b58ee1a21b78 commit r10-9205-ga38b0c6d62d90a5a30cbd00d32e7b58ee1a21b78 Author: Marek Polacek <pola...@redhat.com> Date: Wed Dec 2 14:33:13 2020 -0500 c++: ICE with -fsanitize=vptr and constexpr dynamic_cast [PR98103] -fsanitize=vptr initializes all vtable pointers to null so that it can catch invalid calls; see cp_ubsan_maybe_initialize_vtbl_ptrs. That means that evaluating a vtable reference can produce a null pointer in this mode, so cxx_eval_dynamic_cast_fn should check that and give and error. gcc/cp/ChangeLog: PR c++/98103 * constexpr.c (cxx_eval_dynamic_cast_fn): If the evaluating of vtable yields a null pointer, give an error and return. Use objtype. gcc/testsuite/ChangeLog: PR c++/98103 * g++.dg/ubsan/vptr-18.C: New test. (cherry picked from commit 0221c656bbe5b4ab54e784df3b109c60cb27e5b6)