Subject: Re: [ub] type punning through congruent base class?
From: Gabriel Dos Reis (gdr_at_[hidden])
Date: 2014-01-17 22:13:47
| But how do you know what object is unconstructed?
I do not understand the question; could you clarify?
| An unconstructed object
| pops into existence when you perform an access, and that's enough to validate
| my awful example. This is what I meant by "retroactive."
I don't understand. We define what it means for a raw memory to be constructed as an object.
| Inside a constructor, the type of *this is well-defined, and the exception is
| granted over a limited scope. Outside a constructor, it's a free for all.
I don't understand this. I am saying that if you get dynamically allocated storage of proper alignment and size, then the first write access is, by definition, construction of an object of type given by the lvalue used to perform the write.
| I don't know about rules in C,
the relevant rules have been extensively referenced in this thread. There were a couple of messages specifically dedicated to that last night.
|but as far as I know in C++, you can just
| arbitrarily decide to reinterpret bytes of memory as one POD or another, as
| long as they are "congruent," by mangling the concepts of lifetime and
SG12 list run by herb.sutter at gmail.com