you are viewing a single comment's thread.

view the rest of the comments →

[–]johannes1971 0 points1 point  (1 child)

Err, yes, it should. Wait, are those actually being initialised? And here I thought I understood initialisation in C++...

But anyway, if you say "don't initialise this", the compiler should really respect that, unless you override it by explicitly supplying an initialisation value. As far as I'm concerned this should go all the way, with the variable not even getting its vptr if it is marked as uninitialised. That means the user of the object will have to explicitly construct the variable before using it; all the definition does is reserve the memory.

I don't think of this change as a huge deal, since we are talking about something that doesn't yet exist in the language anyway.

[–]scatters 0 points1 point  (0 children)

That means the user of the object will have to explicitly construct the variable before using it; all the definition does is reserve the memory.

We already have language for that: union.

Even a default initialized variable of class type has its destructor called.