Title
atomics with floating-point
Status
resolved
Section
[atomics]
Submitter
Herb Sutter

Created on 2008-10-17.00:00:00 last changed 163 months ago

Messages

Date: 2010-10-21.18:28:33

Proposed resolution:

Change the note in [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]

Date: 2010-12-05.14:14:49

[ 2009-10 Santa Cruz: ]

NAD EditorialResolved. Addressed by N2992.

Date: 2010-10-21.18:28:33

[ 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 [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]

Date: 2010-10-21.18:28:33

[ Summit: ]

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

Date: 2008-10-17.00:00:00

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).

History
Date User Action Args
2010-12-05 14:14:49adminsetstatus: nad editorial -> resolved
2010-10-21 18:28:33adminsetmessages: + msg4390
2010-10-21 18:28:33adminsetmessages: + msg4389
2010-10-21 18:28:33adminsetmessages: + msg4388
2010-10-21 18:28:33adminsetmessages: + msg4387
2008-10-17 00:00:00admincreate