C++ Logo

liaison

Advanced search

Re: [isocpp-wg14/wg21-liaison] [SC22WG14.26035] constexpr atomic in C++ compatibility concerns

From: Martin Uecker <ma.uecker_at_[hidden]>
Date: Thu, 27 Jun 2024 20:05:03 +0200
Am Donnerstag, dem 27.06.2024 um 19:28 +0300 schrieb Ville Voutilainen via Liaison:
> On Thu, 27 Jun 2024 at 00:02, Niall Douglas <s_sourceforge_at_[hidden]> wrote:
> > We have layout compatibility between `_Atomic` and its equivalent
> > `std::atomic<>`
>
> I don't think we actually do. Or, quoth a vendor, "No. It's qoi and
> GCC fails at it in some cases".

There is an incompatibility between Clang and GCC and
related C++ libraries on the same architecture:

https://github.com/llvm/llvm-project/issues/26836

>
> > and in real world code in a mixed C and C++ codebase
> > people rely on the above functions being interchangeable when operating
> > on the same memory i.e. a header file might declare a struct member as
> > `std::atomic` if `__cplusplus`, and `_Atomic` if not.
>
> Right, but making those functions constexpr in C++ doesn't change the layout
> of anything, and it doesn't change the runtime behavior of anything,
> so the functions remain interoperable on platforms where they
> are interoperable to begin with.

Yes, this change seems unproblematic.

Martin

Received on 2024-06-27 18:05:07