C++ Logo

std-proposals

Advanced search

Re: [std-proposals] std::atomic_pointer_pair

From: Thiago Macieira <thiago_at_[hidden]>
Date: Fri, 02 Jan 2026 11:24:55 -0300
On Thursday, 1 January 2026 19:52:18 Brasilia Standard Time connor horman via
Std-Proposals wrote:
> I'd note that this is not quite true - you can implement load/store using
> CAS (as long as you aren't doing a load on read-only memory). Store is just

And as I said before, the compiler can't know that a load is from read-write
memory, so if it sees a load() on const std::atomic with no unconditional
store, it MUST assume that it could be from read-only memory. This means all
other std::atomic of the same type or aliasing it could be this one and
therefore it must use a locked load for this type, all throughout the program.

In any case, the GCC bugzilla entry is correct: the compiler is allowed to
inline what libatomic will do and *should* do that.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel Data Center - Platform & Sys. Eng.

Received on 2026-01-02 14:25:08