by Joker_vD · 1w ago · 0 comments
double m[1024 * 1024] = ?;
Foo x = ?;
Second, there is a question of semantics. You only get to have 1 destructor, and it's called unconditionally — so we force the author of Foo (or of any class, really) to either 1) write the destructor that can properly destruct an unitialized object which is a bit tricky since reading any of the fields of such an object is UB; 2) shift the blame to the users: "don't do that with this class" — which completely negates your "decided at the call site (not in the class declaration)" point, because this decision is made in the class declaration, and can be made only there, not at the call site.So as usual with C++, we end up with a half-working system, with subtle footguns, pervading all of the program code, and impossible to ignore.
No comments yet.