C++ Logo


Advanced search

Subject: Re: Should std::atomic<T*> have operator->?
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2019-10-22 02:14:52

On 2019-10-22 08:05, Thiago Macieira via Std-Discussion wrote:
> On Monday, 21 October 2019 10:33:02 PDT Andrey Semashev via Std-Discussion
> wrote:
>> I don't think the compiler can ever prove that the pointer is not
>> accessed by any other threads or signal handlers. Even in case of LTO,
>> the compiler can't be sure external threads spawned by OS or shared
>> libraries or signal handlers don't modify the atomic pointer.
> Sometimes it can
> void f()
> {
> std::atomic_ptr<MyType> ptr = get_object();
> ptr->do_one_thing();
> ptr->do_another_thing();
> }

In such pathologic cases I question whether atomic is needed in the
first place.

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

Older Archives on Google Groups