https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104706
Bug ID: 104706 Summary: make_unique cannot create struct of size of 0 due to default_delete's static_assert failure Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: nickhuang99 at hotmail dot com Target Milestone: --- See code in compiler explorer: https://www.godbolt.org/z/cb8973Ys1 struct of size of 0 does have its usage and it is supported by GNU C (https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html). However, make_unique makes it impossible to create such an unique_ptr because its default_delete requires "A" must have non-zero size. struct A{ alignas(int[0]) int ptr[0]; }; void test(){ unique_ptr<A> ptr=make_unique<A>(); } error: static assertion failed: can't delete pointer to incomplete type 83 | static_assert(sizeof(_Tp)>0, | ~~~~~~~~~~~^~ I am not arguing that static_assert is reasonable. My point is that "make_shared" can actually deal this properly. i.e. shared_ptr ptr=make_shared<A>(); gives no error at all.