https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96946
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- I don't know what the problem is, the code should be roughly equivalent to: #include <new> namespace x __attribute__((visibility("default"))) { template<typename T> struct buffer { alignas(__alignof__(T)) unsigned char buf[sizeof(T)]; void* addr() { return static_cast<void*>(buf); } T* ptr() { return static_cast<T*>(addr()); } }; } struct IReporterFactory { virtual ~IReporterFactory() = default; }; class ReporterFactory : public IReporterFactory {}; int main() { auto p = new x::buffer<ReporterFactory>; ::new(p->addr()) ReporterFactory; p->ptr()->~ReporterFactory(); delete p; } And clang has no problem with that (as expected). Is it normal for cfi-unrelated-cast to just trap on a UD2 instruction, rather than giving a UBsan diagnostic?