https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68508
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Author: jakub Date: Thu Nov 26 10:21:42 2015 New Revision: 230933 URL: https://gcc.gnu.org/viewcvs?rev=230933&root=gcc&view=rev Log: PR c++/68508 * cp-tree.h (cp_ubsan_maybe_instrument_downcast): Add INTYPE argument. * cp-ubsan.c (cp_ubsan_maybe_instrument_downcast): Likewise. Use it instead of or in addition to TREE_TYPE (op). Use is_properly_derived_from, return NULL_TREE if TREE_TYPE (intype) and TREE_TYPE (type) are the same type minus qualifiers. * typeck.c (build_static_cast_1): Adjust callers. * g++.dg/ubsan/pr68508.C: New test. Added: branches/gcc-5-branch/gcc/testsuite/g++.dg/ubsan/pr68508.C Modified: branches/gcc-5-branch/gcc/cp/ChangeLog branches/gcc-5-branch/gcc/cp/cp-tree.h branches/gcc-5-branch/gcc/cp/cp-ubsan.c branches/gcc-5-branch/gcc/cp/typeck.c branches/gcc-5-branch/gcc/testsuite/ChangeLog