Re: using C11's _Atomic()
[email protected] (Leon Timmermans) Thu, 7 May 2026 01:10:53 +0200
| Newsgroups | perl.perl5.porters |
|---|---|
| Message-ID | <CAHhgV8hEhzrZ_9Lp+uCOkncvkFyPSP0Oz3P3SJ8sG-n6GRxXHA@mail.gmail.com> |
On Mon, May 4, 2026 at 3:40 AM Tony Cook <[email protected]> wrote: > On Mon, May 04, 2026 at 02:25:34AM +0200, Leon Timmermans wrote: > > That can be worked around by using std::atomic<int> instead of > _Atomic(int) > > in C++ mode (and including atomic). > > I couldn't find anything that indicated they were guaranteed to be > compatible - does an _Atomic<long long> have the same ABI as > atomic<long long>? > > They do provide all the same type aliases though, so if they aren't > compatible C++ code that uses <atomic> and <stdatomic.h> is going to > be painful. > > I saw one claim that it is UB: > > > https://stackoverflow.com/questions/53898429/interoperabilty-between-c-and-c-atomics#answer-53898931 > > but they might be wrong. Strictly it's probably UB, but practically any lock-free atomic type should compile down to its underlying type as its representation in either case, so I'm not overly worried until I've seen proof otherwise. Leon