Subject: Re: About the description of [basic.life]/6
From: Tadeus Prastowo (tadeus.prastowo_at_[hidden])
Date: 2020-04-20 02:56:15
On Mon, Apr 20, 2020 at 3:01 AM Andrew Schepler <aschepler_at_[hidden]> wrote:
> On Sun, Apr 19, 2020 at 7:18 PM Tadeus Prastowo <tadeus.prastowo_at_[hidden]> wrote:
>> On Sun, Apr 19, 2020 at 6:10 PM Andrew Schepler <aschepler_at_[hidden]> wrote:
>> >> > p->~std::string();
>> >> > // The lifetime of the object p pointed at has ended, but its storage has not been reused or released.
>> >> Yes.
>> >> > // At this point, how can p be used and how may it not be used?
>> >> In accordance with Sentence-A, -B, and -C.
>> > Wasn't that what you said applied to pb in the Standard example after the storage for the object it pointed at was reused? What is the difference in applicable Standard rules between pb and this p? Or what other normative effect, if any, does the word "reused" in Sentence-X have?
>> I don't understand you at this point. In my approach, `p' is a
>> `pointer that represents the address of the storage location where the
>> object will be or was located'. More precisely, in your example, `p'
>> is a `pointer that represents the address of the storage location
>> where the object was located'. At this point in your example,
>> Sentence-Y does not apply to `p' because we are not dealing with an
>> object destruction. Therefore, it leaves Sentence-A, -B, and -C.
> I'm asking about your interpretation applied to a comparison between:
> (1) In the example in Standard [basic.life]/6 immediately following Sentence-C, which you discussed earlier in the thread, the permitted/prohibited uses of pointer "pb" just after "pb->mutate();"
> (2) In my example with a union, the permitted/prohibited uses of pointer "p" just after "p->~std::string();"
> I thought you had implied that for case (1), Sentence-Y does not apply, but Sentences-A, -B, and -C all apply. But maybe I misunderstood, since I'm having trouble picking quotes that clearly say those things.
Sentence-Y does not apply to (1) because, immediately after the
statement `pb->mutate();', the context is not within an object
construction/destruction. Instead, Sentence-A, -B, and -C all apply
to (1) since the context is not within an object
> From this last exchange, it does seem in case (2) you say Sentence-Y does not apply, but Sentences-A, -B, and -C all apply.
That's true for the same aforementioned reason.
> Sentence-X contains the phrase "after the lifetime of an object has ended and before the storage which the object occupied is reused or released". This describes case (2) since the lifetime of the `std::string` has ended but its storage has not been reused or released. (The storage will be released at the end of the compound statement, per the automatic storage duration rules.) This does not describe case (1) since the point in question is after the storage has been reused.
Yes, that's right.
> Presumably there is some difference in the applicable Standard rules between case (1) and case (2) because of the condition in Sentence-X. What would you say those differences are?
The difference is that in (1), Sentence-Y can no longer apply because
the storage is already reused. In contrast, in (2), Sentence-Y can
still apply because the storage is not already reused. Specifically,
if after the statement "p->~std::string();" exists a construction of
an object in the storage, Sentence-Y applies to the first of such a
construction for the usage of `any pointer that represents the address
of the storage location'. For example, if the pointer `p' is passed
to the constructor, then Sentence-Y applies to the usage of `p' within
> Or if you disagree with something above, does it cause a difference between some other pair of situations?
I think we have no disagreement so far.
-- Best regards, Tadeus
STD-DISCUSSION list run by firstname.lastname@example.org
Older Archives on Google Groups