C++ Logo

std-proposals

Advanced search

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

From: Jonathan Wakely <cxx_at_[hidden]>
Date: Tue, 20 Jun 2023 08:45:27 +0100
On Tue, 20 Jun 2023, 06:10 Jeremy Hurwitz via Std-Proposals, <
std-proposals_at_[hidden]> 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
>>
>> 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.
>
> Looks like the trivially-destructible part still applies in C++20.
>

Please see https://cplusplus.github.io/LWG/lwg-active.html#submit_issue for
how to submit a library issue, thanks!

Received on 2023-06-20 07:45:42