* libstdc++: the specialization atomic_ref<bool> should use the primary template
@ 2024-05-22 23:05 Lebrun-Grandie, Damien
0 siblings, 0 replies; only message in thread
From: Lebrun-Grandie, Damien @ 2024-05-22 23:05 UTC (permalink / raw)
To: libstdc++; +Cc: gcc-patches
[-- Attachment #1.1: Type: text/plain, Size: 50 bytes --]
See patch attached to this email.
Best,
Damien
[-- Attachment #2: 0001-libstdc-the-specialization-atomic_ref-bool-should-us.patch --]
[-- Type: application/octet-stream, Size: 1964 bytes --]
From 2ef83da01b9a8849fb94c32608819b51bbbb91a7 Mon Sep 17 00:00:00 2001
From: Damien L-G <dalg24@gmail.com>
Date: Wed, 22 May 2024 17:43:45 -0400
Subject: [PATCH] libstdc++: the specialization atomic_ref<bool> should use the
primary template
Per [[atomics.ref.int]](https://eel.is/c++draft/atomics.ref.generic#atomics.ref.int)
`bool` is excluded from the list of integral types for wich there is a
specialization of the `atomic_ref` class template and
[*Note 1*](https://eel.is/c++draft/atomics.ref.generic#atomics.ref.int-note-1)
clearly states that `atomic_ref<bool>` "uses the primary template"
instead.
```c++
void test() {
bool x = true;
std::atomic_ref const a{x};
a &= false; // error should indicate that the compiler
// could not find a matching 'operator&='
// but currently fails in the instantiation
// of implementation details.
}
```
I also expect that one should be able to detect that all the
`fetch_<key>` member functions and other arithmetic operators are not
valid expressions. Maybe that could be the basis for testing the
correct behavior is implemented. See https://godbolt.org/z/1eor9TbYj
Signed-off-by: Damien L-G <dalg24@gmail.com>
---
libstdc++-v3/include/bits/atomic_base.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libstdc++-v3/include/bits/atomic_base.h b/libstdc++-v3/include/bits/atomic_base.h
index 062f1549740..7c342d3bcd0 100644
--- a/libstdc++-v3/include/bits/atomic_base.h
+++ b/libstdc++-v3/include/bits/atomic_base.h
@@ -1478,7 +1478,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#undef _GLIBCXX20_INIT
template<typename _Tp,
- bool = is_integral_v<_Tp>, bool = is_floating_point_v<_Tp>>
+ bool = is_integral_v<_Tp> && !is_same_v<_Tp, bool>,
+ bool = is_floating_point_v<_Tp>>
struct __atomic_ref;
// base class for non-integral, non-floating-point, non-pointer types
--
2.39.3 (Apple Git-146)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-05-22 23:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-22 23:05 libstdc++: the specialization atomic_ref<bool> should use the primary template Lebrun-Grandie, Damien
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).