[ub] type punning through congruent base class?
Herb Sutter
hsutter at microsoft.com
Thu Jan 16 20:41:25 CET 2014
Matt quoted:
"The lifetime of an object of type T begins when:
— storage with the proper alignment and size for type T is obtained, and
— if the object has non-trivial initialization, its initialization is complete."
Perhaps the necessary fix is to strike “if the object has non-trivial initialization” here. I don’t see why trivial constructors are special – sure, they don’t do anything, but they are notionally important.
A bag of memory of alignment and size suitable for T is-not-a T object until its (possibly trivial) ctor is called on that memory – it seems wrong for that to be true for all T except trivially-constructible T’s (with implicit universal type-punning for all types <= sizeof(T)).
Herb
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.open-std.org/pipermail/ub/attachments/20140116/0fbf4572/attachment.html
More information about the ub
mailing list