r/cpp • • Jul 29 '26

C++26: Reducing undefined behaviour

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

48 comments sorted by

View all comments

Show parent comment

24

u/TheThiefMaster C++latest fanatic (and game dev) Jul 29 '26

This was confusing to me too, but I think it's actually a compile error now regardless because the compiler can't verify that it's trivially destructible without the class definition.

3

u/Potterrrrrrrr Jul 29 '26

Yep, that was my takeaway too. Originally it would compile but was only defined behaviour if you hadn’t overridden delete or implemented a destructor (because neither would be able to be called without the compiler knowing the full type), because yeah like you said the compiler can’t prove any of those things with an incomplete type. Now it just rejects any ambiguity which makes a lot more sense.