Submitter: Martin Sebor
Submission Date: March 22, 2014
Subject: atomic_load functions missing const qualifier

Summary

The synopsis of the atomic_load pair of generic functions specified in 7.17.7.2 shows that they accept pointers to a volatile- (bot not const-) qualified type:

          #include <stdatomic.h>

          C atomic_load(volatile A *object);
          C atomic_load_explicit(volatile A *object,
                                 memory_order order);
      

The absence of the const qualifier implies that the functions cannot be called with an argument of type const A* since there is no such conversion.

However, since neither function modifies its argument, there is no need to prevent it from being called with an argument of type const A*. And, in fact, the latest draft C++ standard as of this writing, N3936, does provide an overload of each function that takes a const volatile pointer.

Suggested Technical Corrigendum

In section 7.17.7.2, paragraph 1, Synopsis, modify the declarations of the atomic_load pair of generic functions as indicated below:

          #include <stdatomic.h>

          C atomic_load(const volatile A *object);
          C atomic_load_explicit(const volatile A *object,
                                 memory_order order);