Subject: Re: [ub] type punning through congruent base class?
From: Herb Sutter (hsutter_at_[hidden])
Date: 2014-01-16 13:41:25
"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)).
SG12 list run by herb.sutter at gmail.com