std::unique_ptr allows construction from std::unique_ptr of derived type as per [unique.ptr.single.asgn] and [unique.ptr.single.ctor]. If std::default_delete is used with std::unique_ptr, then after such construction a delete is called on a pointer to base. According to [expr.delete] calling a delete on a non similar object without a virtual destructor is an undefined behavior. This patch turns that undefined behavior into static assertions inside std::unique_ptr. Changelog: * include/bits/unique_ptr.h: Add static asserts that deleting by pointer to base in unique_ptr does not cause UB * testsuite/20_util/unique_ptr/assign/slicing_neg.cc: New test. -- Best regards, Antony Polukhin