Subject: Re: [ub] type punning through congruent base class?
From: Gabriel Dos Reis (gdr_at_[hidden])
Date: 2014-01-16 16:10:06
| In C++ we'd like to say that _assignment_ must be to an object that
| already exists,
Bingo! Except that it is not a wish, it is something we have always done since day 1 :-)
And we have always carefully made a distinction between assignment and other things that may start lifetime.
| which pushes us towards the only other possible
| candidate for starting the lifetime, which is the allocation. That
| doesn't work out well either.
Again, I think we may be reading too much into the 'allocation' blurb.
| Trying to merge the model of C (effective type established by
| declarations or by assignments or memcpy/memmove, no explicit
| initialization/destruction step) with the newer model of C++ (lifetime
| controlled by initialization/destruction) is decidedly non-trivial.
I agree with that -- but it isn't impossible.
It is fundamental and worth doing.
There are reasons to conceive that future C++ implementations would be more "checking" than past implementations were -- the movement has already begun, with several implementations now offering some form of "undefined behavior sanitizers". This in turn was in response to more and more sophisticated translators that start exploiting just about every bit of the language spec. There are surely more reasons; I'm just scratching the surface here.
SG12 list run by herb.sutter at gmail.com