Title
Pointless std-atomic alias template
Status
new
Section
[stdatomic.h.syn]
Submitter
Jan Schultke

Created on 2026-06-18.00:00:00 last changed 6 days ago

Messages

Date: 2026-06-20.12:50:41

Proposed resolution:

This wording is relative to N5046.

  1. Modify [stdatomic.h.syn], header <stdatomic.h> synopsis, as indicated:

    template<class T>
      using std-atomic = std::atomic<T>; // exposition only
    
    #define _Atomic(T) std-atomic<T>std::atomic<T>;
    
Date: 2026-06-20.15:24:13

Consider the following example:

#include <stdatomic.h>

struct _Atomic(int) x; // MSVC rejects, GCC and Clang accept

GCC and Clang incorrectly accept this example because they expand the `_Atomic` macro directly to `std::atomic` instead of the exposition-only std-atomic alias template ([stdatomic.h.syn]), which allows the use of a preceding `struct` keyword.

While the wording is clear, the exposition-only std-atomic alias template causes disagreement among implementers (see discussion at here and here). P0943R6 never actually intended for an alias template to exist as part of its design. The alias template is intended to hint that the expansion of the `_Atomic` macro to `std::atomic` does not require an inclusion of the <atomic> header.

However, `std::atomic` still appears directly inside the <stdatomic.h> synopsis, so it is unclear how std-atomic contributes to that goal.

History
Date User Action Args
2026-06-20 12:50:41adminsetmessages: + msg16492
2026-06-18 00:00:00admincreate