https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68508
--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Created attachment 36822 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36822&action=edit gcc6-pr68508.patch Untested GCC 6 fix. So, my first patch for this was the gcc5-* one, just let the code ignore the instrumentation. But the second question is why are we actually instrumenting this, the cast in that case is from A * to A &, so it is the same class. And here it seems that DERIVED_FROM_P returns true even for the same type used as type and base, plus in one of the two cases where the downcast routine is called the caller already adjusts the op through build_base_path and we already don't have the original type. My understanding has been that we want to instrument only downcasts, and A * to A & is not a downcast IMHO. Though, perhaps for GCC 5.x backport the first patch is safer.