[Bug libstdc++/88996] Implement P0439R0 - Make std::memory_order a scoped enumeration.

2019-03-06 Thread emsr at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88996

emsr at gcc dot gnu.org changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #8 from emsr at gcc dot gnu.org ---
This was committed 269372.

[Bug libstdc++/88996] Implement P0439R0 - Make std::memory_order a scoped enumeration.

2019-03-04 Thread emsr at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88996

--- Comment #7 from emsr at gcc dot gnu.org ---
Author: emsr
Date: Mon Mar  4 20:11:14 2019
New Revision: 269372

URL: https://gcc.gnu.org/viewcvs?rev=269372=gcc=rev
Log:
2019-03-04  Edward Smith-Rowland  <3dw...@verizon.net>

PR libstdc++/88996 Implement P0439R0
Make std::memory_order a scoped enumeration.
* include/bits/atomic_base.h: For C++20 make memory_order a scoped
enum,
add variables for the old enumerators.  Adjust calls.
* testsuite/29_atomics/headers/atomic/types_std_c++2a.cc: New test.
* testsuite/29_atomics/headers/atomic/types_std_c++2a_neg.cc: New test.


Added:
trunk/libstdc++-v3/testsuite/29_atomics/headers/atomic/types_std_c++2a.cc
   
trunk/libstdc++-v3/testsuite/29_atomics/headers/atomic/types_std_c++2a_neg.cc
Modified:
trunk/libstdc++-v3/ChangeLog
trunk/libstdc++-v3/include/bits/atomic_base.h

[Bug libstdc++/88996] Implement P0439R0 - Make std::memory_order a scoped enumeration.

2019-01-22 Thread emsr at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88996

--- Comment #6 from emsr at gcc dot gnu.org ---
Created attachment 45502
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45502=edit
New patch, C++20 only, several fixes, no memory_order ops.

Retesting.

[Bug libstdc++/88996] Implement P0439R0 - Make std::memory_order a scoped enumeration.

2019-01-22 Thread emsr at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88996

--- Comment #5 from emsr at gcc dot gnu.org ---
I was a bit surprised I "needed" these. There are apparently some uses of
these.
I'll roll back and show you...

/home/ed/obj/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/atomic_base.h:104:7:
error: no match for ‘operator|’ (operand types are ‘std::memory_order’ and
‘std::memory_order’)
  103 | return memory_order(__cmpexch_failure_order2(__m &
__memory_order_mask)
  |
~~~
  | |
  | std::memory_order
  104 |   | (__m & __memory_order_modifier_mask));
  |   ^ 
  |  |
  |  std::memory_order

Ok, I'm casting:
  | __memory_order_modifier(__m & __memory_order_modifier_mask));

This will work without the operators.
Those are sequatial flags.
Killed the ops, fix some more sadness and retest.

[Bug libstdc++/88996] Implement P0439R0 - Make std::memory_order a scoped enumeration.

2019-01-22 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88996

--- Comment #4 from Jonathan Wakely  ---
+  inline constexpr memory_order
+  operator&(memory_order __m1, memory_order __m2)
+  { return memory_order(int(__m1) & int(__m2)); }
+
+  inline constexpr memory_order
+  operator|(memory_order __m1, memory_order __m2)
+  { return memory_order(int(__m1) | int(__m2)); }

What are these operators for? One of the main points of P0439 was that this
isn't a bitmask type, and combining the values doesn't make sense. Quoting the
paper:

> a scoped enumeration is more strongly typed, disallowing implicit
> conversion to integers, and preventing nonsensical expressions such as
> memory_order_acquire|memory_order_release (which could be mistakenly
> assumed to be equivalent to memory_order_acq_rel) or ~memory_order_relaxed.

[Bug libstdc++/88996] Implement P0439R0 - Make std::memory_order a scoped enumeration.

2019-01-22 Thread redi at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88996

Jonathan Wakely  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2019-01-22
 Ever confirmed|0   |1

--- Comment #3 from Jonathan Wakely  ---
The ABI says the mangling is the same for scoped and unscoped enumeration
types. There are some corner cases with decltype expressions in function
template declarations, where the enumerator names show up, but I don't expect
them to happen in real code.

I'm not sure if we want to do this for older standards though, it wasn't a DR.

[Bug libstdc++/88996] Implement P0439R0 - Make std::memory_order a scoped enumeration.

2019-01-22 Thread emsr at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88996

--- Comment #2 from emsr at gcc dot gnu.org ---
Still testing BTW.

[Bug libstdc++/88996] Implement P0439R0 - Make std::memory_order a scoped enumeration.

2019-01-22 Thread emsr at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88996

emsr at gcc dot gnu.org changed:

   What|Removed |Added

 CC||emsr at gcc dot gnu.org

--- Comment #1 from emsr at gcc dot gnu.org ---
Created attachment 45499
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45499=edit
Patch that just does the thing for C++11 onwards.

I did

ed@bad-horse:~/bin$ nm  lib64/libstdc++.so | grep memory_order
000a9120 T _ZNSt9__atomic011atomic_flag12test_and_setESt12memory_order
000a9170 T _ZNSt9__atomic011atomic_flag5clearESt12memory_order
000a9120 T
_ZNVSt9__atomic011atomic_flag12test_and_setESt12memory_order@@GLIBCXX_3.4.11

and

ed@bad-horse:~/bin$ nm  lib32/libstdc++.so | grep memory_order
0008ae00 T _ZNSt9__atomic011atomic_flag12test_and_setESt12memory_order
0008ae70 T _ZNSt9__atomic011atomic_flag5clearESt12memory_order
0008ae00 T
_ZNVSt9__atomic011atomic_flag12test_and_setESt12memory_order@@GLIBCXX_3.4.11
0008ae70 T _ZNVSt9__atomic011atomic_flag5clearESt12memory_order@@GLIBCXX_3.4.11

on x96_64-linux.

This is what all teh abi files have.
We'll need to check this on all the targets.