C++ Logo

std-proposals

Advanced search

Re: Allowing access to object representations

From: Language Lawyer <language.lawyer_at_[hidden]>
Date: Sun, 18 Aug 2019 02:16:08 +0300
On 18/08/2019 01:40, sdkrystian via Std-Proposals wrote:
> Ok, look at it like this:
>
> Given this code:
>
> struct A { };
>
> struct B : A { int a; };
>
> Assuming the implementation chooses to make the base class have zero size, how exactly would the object representation of the base class appear in the derived class?

[basic.compound]/3:
> A value of a pointer type that is a pointer to ... an object represents the address of the first byte in memory occupied by the object

Pointer to an object of type B and its base class subobject represent the same address ([basic.compound]/4).

According to your proposal,
> The object representation of an object a of type cv T is a sequence of N cv unsigned char objects, that occupy the same storage as a

The storage occupied by the base class subobject of an object of type B "begins" at the storage of the containing object, yet you say that the object representation of the subobject won't "appear" in the object representation of the containing object.

> Sent from my Samsung Galaxy smartphone.
>
> -------- Original message --------
> From: Language Lawyer via Std-Proposals <std-proposals_at_[hidden]>
> Date: 8/17/19 16:39 (GMT-05:00)
> To: std-proposals_at_[hidden]
> Cc: Language Lawyer <language.lawyer_at_[hidden]>
> Subject: Re: [std-proposals] Allowing access to object representations
>
> On 17/08/2019 23:02, sdkrystian via Std-Proposals wrote:
> > > But where the object representation of a zero size base class subobject of `o` will appear?
> > You seem to guarantee that it, despite having zero size, still has sizeof(T) ≠ 0 elements.
> >
> > It won't appear in the enclosing object (the wording only guarantees so for objects of nonzero size); specifying so would just be extraneous wording.
>
> A zero size base class subobject with nonzero elements in its object representation which do not "appear" in its enclosing object's representation sounds weird.
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2019-08-17 18:18:11