Defect Report #459

Previous Defect Report < - > Next Defect Report


Submitter: Martin Sebor
Submission Date: 2014-03-22
Source: WG14
Reference Document: N1807
Version: 1.0
Date: April 2014
Subject: atomic_load 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);
      


Apr 2014 meeting

Proposed Technical Corrigendum

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

          #include <stdatomic.h>

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

to:

          #include <stdatomic.h>

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


Previous Defect Report < - > Next Defect Report