This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of WP status.

3949. std::atomic<bool>'s trivial destructor dropped in C++17 spec wording

Section: [atomics.types.generic.general] Status: WP Submitter: Jeremy Hurwitz Opened: 2023-06-20 Last modified: 2023-11-22

Priority: Not Prioritized

View all issues with WP status.


std::atomic<bool> was originally required to have a trivial default constructor and a trivial destructor [C++11 N3337: Section [atomics.types.generic], Paragraph 5], the same as the integral [C++11 N3337: Section [atomics.types.generic], Paragraph 5] and pointer specializations [C++11 N3337: Section [atomics.types.generic], Paragraph 6]. P0558 rearranged the text, accidentally (as far as we can tell) removing the constructor and destructor requirements from std::atomic<bool>, which has the surprising effect that std::atomic<bool> has no longer the same constructor/destructor guarantees as std::atomic<int>.

C++20 removed the "trivial default constructor" requirement from all specializations. A specialization for floating-point types was added with a trivial destructor [N4861: Section [atomics.types.float], Paragraph 2)].

[2023-10-27; Reflector poll]

Set status to Tentatively Ready after eight votes in favour during reflector poll.

[2023-11-11 Approved at November 2023 meeting in Kona. Status changed: Voting → WP.]

Proposed resolution:

This wording is relative to N4950.

  1. Modify [atomics.types.generic.general] as indicated:

    -1- […]

    -2- The specialization atomic<bool> is a standard-layout struct. It has a trivial destructor.