C++ Logo

std-discussion

Advanced search

Re: [basic.life]/8.5 interpretation

From: jim x <xmh970252187_at_[hidden]>
Date: Sat, 12 Sep 2020 14:12:07 +0800
Ah, I know. If take the `original subobject` of type int as `o1`, and take
the `newly created subobject` of type int as `o2`, I have to say, yes,
because o1 and o2 are transparently replaceable. So, the original
reference `ri` automatically change to refer to the newly subobject. In
this case, P1 is the `original object` of type `S` and P2 is the `newly
created object of type S`, they are the different objects. However, It does
not evidence that `P1` and `P2` can not be the same object, merely in your
example, they refer to the different object. Informally, the
implementation of reference is based on pointer, that means, the address
of the storage is not changed, hence create the same type object in such a
storage, why would the reference be not changed? So, I think, even though
according to the rule [basic.life#8], your case is governed by these rules.
That's my reading.

Andrey Erokhin <language.lawyer_at_[hidden]> 于2020年9月12日周六 上午3:33写道:

> On 11/09/2020 04:56, jim x wrote:
> > The standard rule does not say that, so `ri` does not gurant to refer to
> > the new subobject, because the rule only says:
> >> a new object is created at the storage location which the original
> object
> > occupied, a pointer that pointed to the original object, a reference that
> > referred to the original object, or the name of the original object will
> > automatically refer to the new object.
> >
> > please note the wording `new object` and `original object`. In your
> > example, you created a new object of type `S`
>
> I create 2 new objects. Of type `S` and of type `int`.
>
> > while you possess a reference
> > that referred to the subobject of the original object. which violate
> these
> > rules:
> >> the storage that o2 occupies exactly overlays the storage that
> o1occupied,
> > and.
> >> o1 and o2 are of the same type (ignoring the top-level cv-qualifiers)
> >
> > So, anyhow, Your example is not covered by these rules.
>
> It is covered by [basic.life]/(8.5)
>

Received on 2020-09-12 01:12:23