http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58920
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- The problem is the middle-end treats pointers and references as the same so sometimes it removes the casting between the pointer type and reference types. GCC has no representation of conditional no trapping which is what is needed here.