libstdc++: Give std::memory_order a fixed underlying type [PR89624]
commit99dd1be14172445795f0012b935359e7014a2215
authorJonathan Wakely <jwakely@redhat.com>
Thu, 11 Apr 2024 18:12:48 +0000 (11 19:12 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 15 May 2024 09:18:14 +0000 (15 10:18 +0100)
tree3f8b6c596ca70dfb775f80fc512e20ef14769aa6
parent642f31d6286b8a342130fbface51530befd975fd
libstdc++: Give std::memory_order a fixed underlying type [PR89624]

Prior to C++20 this enum type doesn't have a fixed underlying type,
which means it can be modified by -fshort-enums, which then means the
HLE bits are outside the range of valid values for the type.

As it has a fixed type of int in C++20 and later, do the same for
earlier standards too. This is technically a change for C++17 down,
because the implicit underlying type (without -fshort-enums) was
unsigned before. I doubt it matters in practice. That incompatibility
already exists between C++17 and C++20 and nobody has noticed or
complained. Now at least the underlying type will be int for all -std
modes.

libstdc++-v3/ChangeLog:

PR libstdc++/89624
* include/bits/atomic_base.h (memory_order): Use int as
underlying type.
* testsuite/29_atomics/atomic/89624.cc: New test.
libstdc++-v3/include/bits/atomic_base.h
libstdc++-v3/testsuite/29_atomics/atomic/89624.cc [new file with mode: 0644]