ISO/IEC JTC1 SC22 WG14 N1477 – 2010-05-25
Paul E. McKenney, firstname.lastname@example.org
This document lists some additional errata in the specification of the atomics in the current working draft (n1425, along with proposed wording for their correction.
The list of errata is as follows:
This paragraph needs to add the prohibition against atomic members of unions:
A union can have member functions (including constructors and destructors), but not virtual (10.3) functions. A union shall not have base classes. A union shall not be used as a base class. If a union contains a non-static data member of reference type the program is ill-formed. . At most one non-static data member of a union may have a brace-or-equal-initializer. [ Note: if any non-static data member of a union has a non-trivial default constructor (12.1), copy constructor (12.8), move constructor (12.8), copy assignment operator (12.8), move assignment operator (12.8), or destructor (12.4), the corresponding member function of the union must be user-provided or it will be implicitly deleted (8.4.3) for the union. — end note ]
The example in this paragraph uses a function
that is not defined in this standard.
This needs to change to use
as shown below:
EXAMPLE: A consequence of spurious failure is that nearly all uses of weak compare-and-exchange will be in a loop.
expected = atomic_load(¤t);
do desired = function(expected);
while (!atomic_compare_exchange(¤t, expected, desired));
When a compare-and-exchange is in a loop, the weak version will yield better performance on some platforms. When a weak compare-and-exchange would require a loop and a strong one would not, the strong one is preferable.