From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2116) id A990E3861000; Sun, 12 Jul 2020 19:42:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A990E3861000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1594582924; bh=IeLAI2lciXJYom91sU4KC8hXoCbYfJHc1JdFQwScYNE=; h=From:To:Subject:Date:From; b=tD0WiA88dAgqVsgpbrWq46T8ljY+D0sSLQEvHrSN20e1I2bO9aRhsw5ar+vxH6Mfz HWjGw5AXPOQP0Kjp4nPvlfixH5o+sbytZXMZ/7G98IxfTAfS6JkAQ/2RHLonDQGSln RVnTyJmgiOlibRGROXqJaaOwSswGWuyb0E7TcbLs= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Ian Lance Taylor To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc/devel/gccgo] libstdc++: Strip cv-qualifiers in std::atomic (PR 95282) X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/devel/gccgo X-Git-Oldrev: cc799df98f6eaf73763a069f7854e490a0416573 X-Git-Newrev: e40b11a91cb345db1324c3cb8f75b01e28056693 Message-Id: <20200712194204.A990E3861000@sourceware.org> Date: Sun, 12 Jul 2020 19:42:04 +0000 (GMT) X-BeenThere: libstdc++-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Jul 2020 19:42:04 -0000 https://gcc.gnu.org/g:e40b11a91cb345db1324c3cb8f75b01e28056693 commit e40b11a91cb345db1324c3cb8f75b01e28056693 Author: Jonathan Wakely Date: Tue Jun 16 22:34:55 2020 +0100 libstdc++: Strip cv-qualifiers in std::atomic (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 - _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 - _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; }