Subject: Re: [std-proposals] P1839 and the object representation of subobjects
Date: 2020-07-21 14:51:56
On 21/07/2020 22:44, language.lawyer_at_[hidden] wrote:> In the code:
> QObject *qoptr = ~~~;
> auto c1ptr = reinterpret_cast<C1 *>(
> Â reinterpret_cast<byte *>(qoptr) + off
> assert(c1ptr == &qoptr->c1);
> `reinterpret_cast<byte *>(qoptr) + off` still points to an element of object representation of the `*qoptr` object, not the first element of object representation of its member subobject at the specified offset. P1839R2's changes to reinterpret_cast wording allow conversion between a pointer to an object and its object representation or the first element of its object representation. This code requires std::launder to get a pointer to member subobject.
> So, P1839R2 makes well-defined none of the things we're worried about in the context of QProperty.
To be more correct: yes, the behavior of the first code example becomes well-defined in P1839R2, but the behavior is not what is expected.
STD-PROPOSALS list run by firstname.lastname@example.org
Standard Proposals Archives on Google Groups