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

### 923. atomics with floating-point

Section: 33.5 [atomics] Status: Resolved Submitter: Herb Sutter Opened: 2008-10-17 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [atomics].

View all issues with Resolved status.

Discussion:

Right now, C++0x doesn't have `atomic<float>`. We're thinking of adding the words to support it for TR2 (note: that would be slightly post-C++0x). If we need it, we could probably add the words.

Proposed resolutions: Using `atomic<FP>::compare_exchange` (weak or strong) should be either:

1. ill-formed, or
2. well-defined.

I propose Option 1 for C++0x for expediency. If someone wants to argue for Option 2, they need to say what exactly they want `compare_exchange` to mean in this case (IIRC, C++0x doesn't even assume IEEE 754).

[ Summit: ]

> Move to open. Blocked until concepts for atomics are addressed.

[ Post Summit Anthony adds: ]

> Recommend NAD. C++0x does have `std::atomic<float>`, and both `compare_exchange_weak` and `compare_exchange_strong` are well-defined in this case. Maybe change the note in 33.5.8.2 [atomics.types.operations] paragraph 20 to:

> > [Note: The effect of the compare-and-exchange operations is

> > >     if (!memcmp(object,expected,sizeof(*object)))
> > >         *object = desired;
> > >     else
> > >         *expected = *object;

> > This may result in failed comparisons for values that compare equal if the underlying type has padding bits or alternate representations of the same value. -- end note]

[ 2009-10 Santa Cruz: ]

> NAD Editorial Resolved. Addressed by N2992.

Proposed resolution:

Change the note in 33.5.8.2 [atomics.types.operations] paragraph 20 to:

> [Note: The effect of the compare-and-exchange operations is

> >     if (*object == *expected !memcmp(object,expected,sizeof(*object)))
> >         *object = desired;
> >     else
> >         *expected = *object;

> This may result in failed comparisons for values that compare equal if the underlying type has padding bits or alternate representations of the same value. -- end note]