public inbox for libstdc++-cvs@sourceware.org help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r11-1401] libstdc++: Strip cv-qualifiers in std::atomic<FP> (PR 95282) Date: Tue, 16 Jun 2020 21:35:06 +0000 (GMT) [thread overview] Message-ID: <20200616213506.17823386F447@sourceware.org> (raw) https://gcc.gnu.org/g:e40b11a91cb345db1324c3cb8f75b01e28056693 commit r11-1401-ge40b11a91cb345db1324c3cb8f75b01e28056693 Author: Jonathan Wakely <jwakely@redhat.com> Date: Tue Jun 16 22:34:55 2020 +0100 libstdc++: Strip cv-qualifiers in std::atomic<FP> (PR 95282) This improves the previous fix for PR 95282, and extends it to also apply to the exchange function (which has a similar problem and would become ill-formed with my proposed fix for PR 95378). PR libstdc++/95282 * include/bits/atomic_base.h (__atomic_impl::load): Use the _Val alias instead of deducing _Tp as an unqualified type. (__atomic_impl::exchange): Use the _Val alias to remove volatile from the reinterpret_cast result type. Diff: --- libstdc++-v3/include/bits/atomic_base.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libstdc++-v3/include/bits/atomic_base.h b/libstdc++-v3/include/bits/atomic_base.h index ebcfeb4d51a..015acef83c4 100644 --- a/libstdc++-v3/include/bits/atomic_base.h +++ b/libstdc++-v3/include/bits/atomic_base.h @@ -870,21 +870,21 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { __atomic_store(__ptr, std::__addressof(__t), int(__m)); } template<typename _Tp> - _GLIBCXX_ALWAYS_INLINE _Tp - load(const volatile _Tp* __ptr, memory_order __m) noexcept + _GLIBCXX_ALWAYS_INLINE _Val<_Tp> + load(const _Tp* __ptr, memory_order __m) noexcept { alignas(_Tp) unsigned char __buf[sizeof(_Tp)]; - _Tp* __dest = reinterpret_cast<_Tp*>(__buf); + auto* __dest = reinterpret_cast<_Val<_Tp>*>(__buf); __atomic_load(__ptr, __dest, int(__m)); return *__dest; } template<typename _Tp> - _GLIBCXX_ALWAYS_INLINE _Tp + _GLIBCXX_ALWAYS_INLINE _Val<_Tp> exchange(_Tp* __ptr, _Val<_Tp> __desired, memory_order __m) noexcept { alignas(_Tp) unsigned char __buf[sizeof(_Tp)]; - _Tp* __dest = reinterpret_cast<_Tp*>(__buf); + auto* __dest = reinterpret_cast<_Val<_Tp>*>(__buf); __atomic_exchange(__ptr, std::__addressof(__desired), __dest, int(__m)); return *__dest; }
reply other threads:[~2020-06-16 21:35 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200616213506.17823386F447@sourceware.org \ --to=redi@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ --cc=libstdc++-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).