C++ Logo

STD-DISCUSSION

Advanced search

Subject: Re: About the description of [basic.life]/6
From: yo mizu (mizu2594_at_[hidden])
Date: 2020-04-14 19:20:07


On Wed, Apr 15, 2020 at 2:28 AM Tadeus Prastowo
<tadeus.prastowo_at_[hidden]> wrote:
> Quoting [basic.life]/6 with annotations:
> Before the lifetime of an object has started but after the storage
> which the object will occupy has been allocated or, after the lifetime
> of an object has ended and before the storage which the object
> occupied is reused or released, any pointer that represents the
> address of the storage location where the object will be or was
> located may be used but only in limited ways.
>
> [The sentence above does not apply at this point in the example
> because "the storage which the object occupied is reused".]
>
> For an object under construction or destruction, see [class.cdtor].
>
> [The sentence above does not apply at this point in the example
> because no object is under construction/destruction.]
>
> Otherwise, such a pointer refers to allocated storage
> ([basic.stc.dynamic.deallocation]), and using the pointer as if the
> pointer were of type void*, is well-defined.
>
> [The sentence above applies at this point in the example. Let's name
> this sentence Sentence-A.]
>
> Indirection through such a pointer is permitted but the resulting
> lvalue may only be used in limited ways, as described below.
>
> [The sentence above also applies at this point in the example. Let's
> name this sentence Sentence-B.]

Thank you for your quick reply.

Before the lifetime of an object has started but after the storage
which the object will occupy has been allocated or, after the lifetime
of an object has ended and before the storage which the object
occupied is reused or released, any pointer that represents the
address of the storage location where the object will be or was
located may be used but only in limited ways.
[Sentence-X]

For an object under construction or destruction, see [class.cdtor].
[Sentence-Y]

Otherwise, such a pointer refers to allocated storage, and using the
pointer as if the pointer were of type void*, is well-defined
[Sentence-A]

Indirection through such a pointer is permitted but the resulting
lvalue may only be used in limited ways, as described below
[Sentence-B]

I thought that Sentence-Y and Sentence-A are exclusive and pointers
that meet the requirements of Sentence-X are classified as either
Sentence-Y or Sentence-A.

So you mean, Sentence-X, Sentence-Y and Sentence-A are exclusive?
If so, does Sentence-B can be applied to all sentences (X, Y and A),
or only to Sentence-A?

I thought "such a pointer" in Sentence-A and Sentence-B means "a
pointer that meets the requirements of Sentence-X".
If it's a mistake, what does "such a pointer" mean?

--
Best regards,
yo mizu

STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups