This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
| Other format: | [Raw text] | |
Our <atomic> was implemented (by Benjamin IIRC) based on an early
C++0x draft when the spec was still trying to be valid for both C and
C++. Part of the C compatibility aspect was that std::atomic_int is
allowed to be either a typedef for std::atomic<int> or a base class of
it, so that a C library could define std::atomic_int and then the C++
library could make std::atomic<int> derive from that.
In the final C11 spec atomics work completely differently, and
atomic_int is a typedef for _Atomic int, which is not a valid base
class. So the old C++0x draft's compatibility aim is impossible,
atomic_int can never be the same type in C and C++.
In our implementation, std::atomic_int is a base class of
std::atomic<int>, which has no benefit I can see, but causes
https://gcc.gnu.org/PR60940
Rather than overloading every atomic_op() non-member function to
handle the derived class and the base class, it would be simpler to
just get rid of the base classes and make atomic_xxx a typedef for
atomic<xxx>, as the attached patch does for atomic_{bool,char,schar}.
Does anyone object to that change?
If you object, are you prepared to do the work to fix PR60940? :-)
[Note:- it could probably be simplified even further so atomic<char>
is just:
template<>
struct atomic<char> : public __atomic_base<char>
{
using __atomic_base<char>::__atomic_base;
};
But that could be done later as it wouldn't change anything
observable, making atomic_char a typedef for atomic<char> is the
observable and IMHO important change. -end note]
Attachment:
atomics.txt
Description: Text document
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |