Subject: Re: About the description of [basic.life]/6
From: Tadeus Prastowo (tadeus.prastowo_at_[hidden])
Date: 2020-04-16 07:48:40
On Wed, Apr 15, 2020 at 6:50 PM yo mizu via Std-Discussion
> On Thu, Apr 16, 2020 at 12:36 AM Tadeus Prastowo
> <tadeus.prastowo_at_[hidden]> wrote:
> > Sentence-X is futher elaborated in Sentence-Y where Sentence-Y
> > provides a forward reference, while the pointer defined in Sentence-X
> > is further elaborated in Sentence-A, -B, and -C where Sentence-A, -B,
> > and -C provide details and Sentence-C is the one that starts with "The
> > program has undefined behavior if:" and continues to [basic.life]6.1
> > up to 6.5.
> Thank you for explaining so politely and thoroughly.
> I pretty much got it!
> 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
> ("such a pointer")
> may be used but only in limited ways.
> (That means, "such a pointer" that meets "Condition-1" may be used in
> limited ways. It does not say anything specific.)
> For an object under construction or destruction,
> (Condition-2 (special case of Condition-1))
And, I think Condition-2 is the _only_ special case of Condition-1 as
of now. But, CMIIW.
> see [class.cdtor].
> (That means, "such a pointer" that meets "Condition-2" can be used as
> described in [class.cdtor]).
> Otherwise, such a pointer
> refers to allocated storage,
That is, Condition-3 is satisfied when "such pointer" fails to satisfy
> and using the pointer as if the pointer were of type void*, is well-defined.
> (That means, "such a pointer" that meets "Condition-3" and does not
> meet "Condition-2" can be used as if the pointer were of type void*.)
Not Condition-2 but Condition-1 because Condition-2 is only a forward
reference to another part of the standard.
> Indirection through such a pointer is permitted but the resulting
> lvalue may only be used in limited ways, as described below.
That sentence's "as described below" refers to [basic.life]/7, not the
> The program has undefined behavior if:
> (That means, "such a pointer" can be used as ...)
No, that means that, if a standard behavior is expected, "such a
pointer" _cannot_ be used as ...
> Is it correct?
More or less as per my comments.
> Best regards,
> Yo Mizu
-- Best regards, Tadeus
STD-DISCUSSION list run by firstname.lastname@example.org
Older Archives on Google Groups