C++ Logo


Advanced search

Re: [std-proposals] std::atomic<bool> trivial constructor/destructor dropped in C++17 spec wording

From: Andrey Semashev <andrey.semashev_at_[hidden]>
Date: Tue, 20 Jun 2023 11:40:24 +0300
On 6/20/23 08:10, Jeremy Hurwitz via Std-Proposals wrote:
> > Is this a defect in the current spec? Thanks!
> Since C++17, std::atomic value-initializes its contained value, see:
> http://eel.is/c++draft/atomics#types.operations-2
> <http://eel.is/c++draft/atomics#types.operations-2>
> Therefore it cannot be trivially-constructible. std::atomic<bool> is not
> special in this regard.
> Good catch. Verified via godbolt that
> `std::is_trivially_constructible_v<std::atomic<bool>>` is true in C++17
> and false in C++20. So that defect only applies to C++17 and before.

Yes, I was mistaken there. The change only appeared in C++20, not in C++17.

Received on 2023-06-20 08:40:50