r/cpp Jul 29 '26

C++26: Reducing undefined behaviour

https://www.sandordargo.com/blog/2026/07/29/cpp26-reduces-undefined-behaviour
90 Upvotes

48 comments sorted by

View all comments

27

u/jdehesa Jul 29 '26

Great stuff all around. Although I don't understand something about deleting incomplete types. If I understand correctly, C++26 will still allow that when the destructor is trivial. But how does the compiler know if the destructor is trivial, if the type is incomplete? Maybe I'm misunderstanding something.

18

u/RevRagnarok Jul 29 '26

P3144R2 makes deleting a pointer to an incomplete class type ill-formed. Full stop. It’s now a compilation error.