Boost logo

Boost :

Subject: Re: [boost] [Block Pointer] Question about cycles rationale
From: Rob Stewart (rstewart_at_[hidden])
Date: 2016-03-14 07:35:08

On March 13, 2016 6:36:49 PM EDT, Phil Bouchard <philippeb8_at_[hidden]> wrote:
>So you have a cycle being wiped out by the proxy:
>+-> a1 ---> a2 -+
>| |
>1) a1.~A() will be called
>2) a1.~A() will call
>3) But a2 might have been wiped out already.
>So if you try to access a member in the destructor without explicitly
>checking if it was destroyed already then this will lead to an
>behavior, just like dereferencing a null pointer.
>I could throw an exception when operator -> is used while a cycle is
>being destroyed but I don't think the overhead is worth it for this
>special case only.

Neither answer is great. The exception could occur during shack unwinding, so you couldn't use your pointers in very many contexts. No exception means UB, which means users have to remember a special case and thereby lose safety.

I fail to see how that is better than using weak_ptr. In that case, one must always be explicit rather than remember special cases.


(Sent from my portable computation engine)

Boost list run by bdawes at, gregod at, cpdaniel at, john at