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

4633. Lack of wording to specify that the destruction of an atomic object is not an atomic operation

Section: 32.5.8.2 [atomics.types.operations] Status: New Submitter: jim x Opened: 2026-10-21 Last modified: 2026-10-31

Priority: Not Prioritized

View all other issues in [atomics.types.operations].

View all issues with New status.

Discussion:

Consider the following example:

#include <atomic>
#include <thread>

int main() 
{
  auto ptr = new std::atomic<int>{0};
  auto t1 = std::jthread([&]() {
    (*ptr).load();  // #1 
  });
  auto t2 = std::jthread([&]() {
    using Atomic = std::atomic<int>;
    (*ptr).~Atomic();  // #2 
  });
}

Since neither #1 happens-before nor happens-after #2, and #1 is an atomic operation, whether this program contains a data race depends on whether #2 is a non-atomic operation due to [intro.race] p17:

at least one of which is not an atomic operation

32.5.8.2 [atomics.types.operations] says:

Effects: Initializes the atomic object with the value of T(). Initialization is not an atomic operation (6.10.2 [intro.multithread]).

However, it lacks the wording to explicitly state that the destruction of an atomic object is not an atomic operation.

Proposed resolution: