From 190c644c06369766aa2537851ddbf83b1231b65b Mon Sep 17 00:00:00 2001 From: Philipp Fent Date: Sun, 4 Sep 2022 20:47:34 +0200 Subject: libstdc++: Fix pretty printer tests of tuple indexes Signed-off-by: Philipp Fent libstdc++-v3/ChangeLog: * testsuite/libstdc++-prettyprinters/48362.cc: Fix expected tuple indices. * testsuite/libstdc++-prettyprinters/cxx11.cc: Likewise. --- libstdc++-v3/testsuite/libstdc++-prettyprinters/48362.cc | 2 +- libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx11.cc | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'libstdc++-v3') diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/48362.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/48362.cc index cc91803..af335d0 100644 --- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/48362.cc +++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/48362.cc @@ -29,7 +29,7 @@ main() // { dg-final { note-test t1 {empty std::tuple} } } std::tuple> t2{ "Johnny", 5, {} }; -// { dg-final { regexp-test t2 {std::tuple containing = {\[1\] = "Johnny", \[2\] = 5, \[3\] = empty std::tuple}} } } +// { dg-final { regexp-test t2 {std::tuple containing = {\[0\] = "Johnny", \[1\] = 5, \[2\] = empty std::tuple}} } } std::cout << "\n"; return 0; // Mark SPOT diff --git a/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx11.cc b/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx11.cc index f97640a..bc5978e 100644 --- a/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx11.cc +++ b/libstdc++-v3/testsuite/libstdc++-prettyprinters/cxx11.cc @@ -166,9 +166,9 @@ main() // { dg-final { note-test runiq_ptr {std::unique_ptr = {get() = 0x0}} } } ExTuple tpl(6,7); -// { dg-final { note-test tpl {std::tuple containing = {[1] = 6, [2] = 7}} } } +// { dg-final { note-test tpl {std::tuple containing = {[0] = 6, [1] = 7}} } } ExTuple &rtpl = tpl; -// { dg-final { note-test rtpl {std::tuple containing = {[1] = 6, [2] = 7}} } } +// { dg-final { note-test rtpl {std::tuple containing = {[0] = 6, [1] = 7}} } } std::error_code e0; // { dg-final { note-test e0 {std::error_code = { }} } } -- cgit v1.1 From 25aeb92221659067b5d83c6ca1639374ce9be555 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Wed, 7 Sep 2022 00:17:51 +0000 Subject: Daily bump. --- libstdc++-v3/ChangeLog | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'libstdc++-v3') diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index c9a7f35..78913d8 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,9 @@ +2022-09-06 Philipp Fent + + * testsuite/libstdc++-prettyprinters/48362.cc: Fix expected + tuple indices. + * testsuite/libstdc++-prettyprinters/cxx11.cc: Likewise. + 2022-09-05 Jonathan Wakely * include/std/type_traits (__success_type, __failure_type): Move -- cgit v1.1 From 873d395c2976a8321cec03f21d77e11f746da7c0 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Tue, 6 Sep 2022 10:35:21 -0400 Subject: libstdc++: small dynamic_cast optimization This change speeds up the simple benchmark below by about 40%. struct A { virtual ~A() {} }; struct B: A { } b; A* ap = &b; void *sink; int main() { for (long i = 0; i < 4000000000L; ++i) sink = dynamic_cast(ap); } libstdc++-v3/ChangeLog: * libsupc++/dyncast.cc (__dynamic_cast): Avoid virtual function call in simple success case. --- libstdc++-v3/libsupc++/dyncast.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'libstdc++-v3') diff --git a/libstdc++-v3/libsupc++/dyncast.cc b/libstdc++-v3/libsupc++/dyncast.cc index 853c911..616e4c0 100644 --- a/libstdc++-v3/libsupc++/dyncast.cc +++ b/libstdc++-v3/libsupc++/dyncast.cc @@ -71,6 +71,12 @@ __dynamic_cast (const void *src_ptr, // object started from if (whole_prefix->whole_type != whole_type) return NULL; + // Avoid virtual function call in the simple success case. + if (src2dst >= 0 + && src2dst == -prefix->whole_object + && *whole_type == *dst_type) + return const_cast (whole_ptr); + whole_type->__do_dyncast (src2dst, __class_type_info::__contained_public, dst_type, whole_ptr, src_type, src_ptr, result); if (!result.dst_ptr) -- cgit v1.1 From 66af6e991bf0daf1c41e46400a8f19e87c358cf2 Mon Sep 17 00:00:00 2001 From: Patrick Palka Date: Wed, 7 Sep 2022 10:21:45 -0400 Subject: libstdc++: Optimize is_void and is_null_pointer Instead of defining these in terms of a helper class template and the relatively expensive __remove_cv_t, just declare four explicit specializations of the main template, one for each choice of cv-quals. libstdc++-v3/ChangeLog: * include/std/type_traits (__is_void_helper): Remove. (is_void): Make the primary template derive from false_type, and define four explicit specializations that derive from true_type. (__is_null_pointer_helper, is_null_pointer): Likewise. --- libstdc++-v3/include/std/type_traits | 48 +++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 17 deletions(-) (limited to 'libstdc++-v3') diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index e4d1679..b83e725 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -289,23 +289,30 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // __remove_cv_t (std::remove_cv_t for C++11). template using __remove_cv_t = typename remove_cv<_Tp>::type; + /// @endcond // Primary type categories. - template - struct __is_void_helper + /// is_void + template + struct is_void : public false_type { }; template<> - struct __is_void_helper + struct is_void : public true_type { }; - /// @endcond - /// is_void - template - struct is_void - : public __is_void_helper<__remove_cv_t<_Tp>>::type - { }; + template<> + struct is_void + : public true_type { }; + + template<> + struct is_void + : public true_type { }; + + template<> + struct is_void + : public true_type { }; /// @cond undocumented template @@ -571,19 +578,26 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #define __cpp_lib_is_null_pointer 201309L - template - struct __is_null_pointer_helper + /// is_null_pointer (LWG 2247). + template + struct is_null_pointer : public false_type { }; template<> - struct __is_null_pointer_helper + struct is_null_pointer : public true_type { }; - /// is_null_pointer (LWG 2247). - template - struct is_null_pointer - : public __is_null_pointer_helper<__remove_cv_t<_Tp>>::type - { }; + template<> + struct is_null_pointer + : public true_type { }; + + template<> + struct is_null_pointer + : public true_type { }; + + template<> + struct is_null_pointer + : public true_type { }; /// __is_nullptr_t (deprecated extension). /// @deprecated Non-standard. Use `is_null_pointer` instead. -- cgit v1.1 From cdcc27c1ca9c485c66ac1914e352c79e5048b6b5 Mon Sep 17 00:00:00 2001 From: Patrick Palka Date: Wed, 7 Sep 2022 10:21:51 -0400 Subject: libstdc++: Optimize is_reference Instead of defining is_reference in terms of is_[lr]value_reference, just define it directly. libstdc++-v3/ChangeLog: * include/std/type_traits (is_reference): Make the primary template derive from false_type. Define two partial specializations that derive from true_type. --- libstdc++-v3/include/std/type_traits | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'libstdc++-v3') diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index b83e725..94e73ea 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -611,8 +611,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// is_reference template struct is_reference - : public __or_, - is_rvalue_reference<_Tp>>::type + : public false_type + { }; + + template + struct is_reference<_Tp&> + : public true_type + { }; + + template + struct is_reference<_Tp&&> + : public true_type { }; /// is_arithmetic -- cgit v1.1 From d7f282c4243e24f567b11a5cb6048a27a3df733d Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Tue, 6 Sep 2022 11:58:21 +0100 Subject: libstdc++: Add missing runtime exception to licence notice This file is missing the GCC Runtime Library Exception text in the licence header. That is unintentional, and it should have been present. libstdc++-v3/ChangeLog: * include/std/barrier: Add missing runtime exception. --- libstdc++-v3/include/std/barrier | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'libstdc++-v3') diff --git a/libstdc++-v3/include/std/barrier b/libstdc++-v3/include/std/barrier index 2a26505..997e0a8 100644 --- a/libstdc++-v3/include/std/barrier +++ b/libstdc++-v3/include/std/barrier @@ -13,8 +13,13 @@ // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// You should have received a copy of the GNU General Public License along -// with this library; see the file COPYING3. If not see +// Under Section 7 of GPL version 3, you are granted additional +// permissions described in the GCC Runtime Library Exception, version +// 3.1, as published by the Free Software Foundation. + +// You should have received a copy of the GNU General Public License and +// a copy of the GCC Runtime Library Exception along with this program; +// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // . // This implementation is based on libcxx/include/barrier -- cgit v1.1 From fe2a8ce93c86e05730ee9b975f413cb3fc288d94 Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Thu, 8 Sep 2022 00:18:33 +0000 Subject: Daily bump. --- libstdc++-v3/ChangeLog | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'libstdc++-v3') diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 78913d8..958f6de 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,26 @@ +2022-09-07 Jonathan Wakely + + * include/std/barrier: Add missing runtime exception. + +2022-09-07 Patrick Palka + + * include/std/type_traits (is_reference): Make the primary + template derive from false_type. Define two partial + specializations that derive from true_type. + +2022-09-07 Patrick Palka + + * include/std/type_traits (__is_void_helper): Remove. + (is_void): Make the primary template derive from false_type, + and define four explicit specializations that derive from + true_type. + (__is_null_pointer_helper, is_null_pointer): Likewise. + +2022-09-07 Jason Merrill + + * libsupc++/dyncast.cc (__dynamic_cast): Avoid virtual function + call in simple success case. + 2022-09-06 Philipp Fent * testsuite/libstdc++-prettyprinters/48362.cc: Fix expected -- cgit v1.1 From d3883dc77b1426984c0edea6081f57ed2305c9f2 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Wed, 7 Sep 2022 20:17:04 +0100 Subject: libstdc++: Find make_error_code and make_error_condition via ADL only The new proposed resolution for LWG 3629 says that std::error_code and std::error_condition should only use ADL to find their customization points. This means we need to use a poison pill to prevent lookup from finding overloads in the enclosing namespaces. We can also remove the forward declarations of std::make_error_code and std::make_error_condition, because they aren't needed now. ADL can find them anyway (when std is an associated namespace), and unqualified name lookup will not (and should not) find them. libstdc++-v3/ChangeLog: * include/std/system_error (__adl_only::make_error_code): Add deleted function. (__adl_only::make_error_condition): Likewise. (error_code::error_code(ErrorCodeEnum)): Add using-declaration for deleted function. (error_condition::error_condition(ErrorConditionEnum)): Likewise. * testsuite/19_diagnostics/error_code/cons/lwg3629.cc: New test. * testsuite/19_diagnostics/error_condition/cons/lwg3629.cc: New test. --- libstdc++-v3/include/std/system_error | 18 +++++--- .../19_diagnostics/error_code/cons/lwg3629.cc | 48 ++++++++++++++++++++++ .../19_diagnostics/error_condition/cons/lwg3629.cc | 48 ++++++++++++++++++++++ 3 files changed, 109 insertions(+), 5 deletions(-) create mode 100644 libstdc++-v3/testsuite/19_diagnostics/error_code/cons/lwg3629.cc create mode 100644 libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/lwg3629.cc (limited to 'libstdc++-v3') diff --git a/libstdc++-v3/include/std/system_error b/libstdc++-v3/include/std/system_error index 0504394..e12bb2f 100644 --- a/libstdc++-v3/include/std/system_error +++ b/libstdc++-v3/include/std/system_error @@ -195,7 +195,11 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2) * @{ */ - error_code make_error_code(errc) noexcept; +namespace __adl_only +{ + void make_error_code() = delete; + void make_error_condition() = delete; +} /** Class error_code * @@ -231,7 +235,10 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2) template> error_code(_ErrorCodeEnum __e) noexcept - { *this = make_error_code(__e); } + { + using __adl_only::make_error_code; + *this = make_error_code(__e); + } error_code(const error_code&) = default; error_code& operator=(const error_code&) = default; @@ -330,8 +337,6 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2) operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e) { return (__os << __e.category().name() << ':' << __e.value()); } - error_condition make_error_condition(errc) noexcept; - /** Class error_condition * * This class represents error conditions that may be visible at an API @@ -363,7 +368,10 @@ _GLIBCXX_END_INLINE_ABI_NAMESPACE(_V2) template> error_condition(_ErrorConditionEnum __e) noexcept - { *this = make_error_condition(__e); } + { + using __adl_only::make_error_condition; + *this = make_error_condition(__e); + } error_condition(const error_condition&) = default; error_condition& operator=(const error_condition&) = default; diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_code/cons/lwg3629.cc b/libstdc++-v3/testsuite/19_diagnostics/error_code/cons/lwg3629.cc new file mode 100644 index 0000000..b1e0b7f --- /dev/null +++ b/libstdc++-v3/testsuite/19_diagnostics/error_code/cons/lwg3629.cc @@ -0,0 +1,48 @@ +// { dg-do compile { target c++11 } } + +// 3629. make_error_code and make_error_condition are customization points +// Verify that make_error_code is looked up using ADL only. + +namespace user +{ + struct E1; +} + +// N.B. not in associated namespace of E1, and declared before . +user::E1 make_error_code(user::E1); + +#include // declares std::make_error_code(future_errc) +#include + +namespace user +{ + struct E1 + { + operator std::error_code() const; + }; + + struct E2 + { + operator std::future_errc() const; + }; + + struct E3 + { + operator std::errc() const; + }; +} + +template<> struct std::is_error_code_enum : std::true_type { }; +template<> struct std::is_error_code_enum : std::true_type { }; +template<> struct std::is_error_code_enum : std::true_type { }; + +// ::make_error_code(E1) should not be found by name lookup. +std::error_code e1( user::E1{} ); // { dg-error "here" } + +// std::make_error_code(errc) should not be found by name lookup. +std::error_code e2( user::E2{} ); // { dg-error "here" } + +// std::make_error_code(future_errc) should not be found by name lookup. +std::error_code e3( user::E3{} ); // { dg-error "here" } + +// { dg-error "use of deleted function" "" { target *-*-* } 0 } diff --git a/libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/lwg3629.cc b/libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/lwg3629.cc new file mode 100644 index 0000000..e34b53d --- /dev/null +++ b/libstdc++-v3/testsuite/19_diagnostics/error_condition/cons/lwg3629.cc @@ -0,0 +1,48 @@ +// { dg-do compile { target c++11 } } + +// 3629. make_error_code and make_error_condition are customization points +// Verify that make_error_condition is looked up using ADL only. + +namespace user +{ + struct E1; +} + +// N.B. not in associated namespace of E1, and declared before . +user::E1 make_error_condition(user::E1); + +#include // declares std::make_error_condition(future_errc) +#include + +namespace user +{ + struct E1 + { + operator std::error_code() const; + }; + + struct E2 + { + operator std::future_errc() const; + }; + + struct E3 + { + operator std::errc() const; + }; +} + +template<> struct std::is_error_condition_enum : std::true_type { }; +template<> struct std::is_error_condition_enum : std::true_type { }; +template<> struct std::is_error_condition_enum : std::true_type { }; + +// ::make_error_condition(E1) should not be found by name lookup. +std::error_condition e1( user::E1{} ); // { dg-error "here" } + +// std::make_error_condition(errc) should not be found by name lookup. +std::error_condition e2( user::E2{} ); // { dg-error "here" } + +// std::make_error_condition(future_errc) should not be found by name lookup. +std::error_condition e3( user::E3{} ); // { dg-error "here" } + +// { dg-error "use of deleted function" "" { target *-*-* } 0 } -- cgit v1.1 From 157236dbd621644b3cec50b6cf38811959f3e78c Mon Sep 17 00:00:00 2001 From: Thomas Rodgers Date: Thu, 25 Aug 2022 12:11:40 +0200 Subject: libstdc++: Clear padding bits in atomic compare_exchange This change implements P0528 which requires that padding bits not participate in atomic compare exchange operations. All arguments to the generic template are 'sanitized' by the __builtin_clear_padding intrinsic before they are used in comparisons. This requires that any stores also sanitize the incoming value. Co-authored-by: Jakub Jelinek Co-authored-by: Jonathan Wakely Signed-off-by: Thomas Rodgers libstdc++-v3/ChangeLog: * include/bits/atomic_base.h (__atomic_impl::__maybe_has_padding): New function. (__atomic_impl::clear_padding): Likewise. (__atomic_impl::__compare_exchange): Likewise. (__atomic_impl::compare_exchange_weak): Delegate to __compare_exchange. (__atomic_impl::compare_exchange_strong): Likewise. * include/std/atomic (atomic::atomic(T)): Clear padding when possible in a constexpr function. (atomic::store): Clear padding. (atomic::exchange): Likewise. (atomic::compare_exchange_weak): Use __compare_exchange. (atomic::compare_exchange_strong): Likewise. * testsuite/29_atomics/atomic/compare_exchange_padding.cc: New test. * testsuite/29_atomics/atomic_ref/compare_exchange_padding.cc: New test. --- libstdc++-v3/include/bits/atomic_base.h | 97 +++++++++++++++++----- libstdc++-v3/include/std/atomic | 58 ++++++------- .../29_atomics/atomic/compare_exchange_padding.cc | 42 ++++++++++ .../atomic_ref/compare_exchange_padding.cc | 43 ++++++++++ 4 files changed, 188 insertions(+), 52 deletions(-) create mode 100644 libstdc++-v3/testsuite/29_atomics/atomic/compare_exchange_padding.cc create mode 100644 libstdc++-v3/testsuite/29_atomics/atomic_ref/compare_exchange_padding.cc (limited to 'libstdc++-v3') diff --git a/libstdc++-v3/include/bits/atomic_base.h b/libstdc++-v3/include/bits/atomic_base.h index d29e443..2931554 100644 --- a/libstdc++-v3/include/bits/atomic_base.h +++ b/libstdc++-v3/include/bits/atomic_base.h @@ -33,6 +33,7 @@ #pragma GCC system_header #include +#include // For placement new #include #include #include @@ -952,19 +953,76 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __atomic_fetch_sub(&_M_p, _M_type_size(__d), int(__m)); } }; - /// @endcond - -#if __cplusplus > 201703L - /// @cond undocumented - - // Implementation details of atomic_ref and atomic. namespace __atomic_impl { + // Implementation details of atomic padding handling + + template + constexpr bool + __maybe_has_padding() + { +#if ! __has_builtin(__builtin_clear_padding) + return false; +#elif __has_builtin(__has_unique_object_representations) + return !__has_unique_object_representations(_Tp) + && !is_same<_Tp, float>::value && !is_same<_Tp, double>::value; +#else + return true; +#endif + } + + template + _GLIBCXX_ALWAYS_INLINE _Tp* + __clear_padding(_Tp& __val) noexcept + { + auto* __ptr = std::__addressof(__val); +#if __has_builtin(__builtin_clear_padding) + if _GLIBCXX17_CONSTEXPR (__atomic_impl::__maybe_has_padding<_Tp>()) + __builtin_clear_padding(__ptr); +#endif + return __ptr; + } + // Remove volatile and create a non-deduced context for value arguments. template - using _Val = remove_volatile_t<_Tp>; + using _Val = typename remove_volatile<_Tp>::type; + + template + _GLIBCXX_ALWAYS_INLINE bool + __compare_exchange(_Tp& __val, _Val<_Tp>& __e, _Val<_Tp>& __i, + bool __weak, memory_order __s, memory_order __f) noexcept + { + __glibcxx_assert(__is_valid_cmpexch_failure_order(__f)); + + using _Vp = _Val<_Tp>; + + if _GLIBCXX17_CONSTEXPR (__atomic_impl::__maybe_has_padding<_Vp>()) + { + // We must not modify __e on success, so cannot clear its padding. + // Copy into a buffer and clear that, then copy back on failure. + alignas(_Vp) unsigned char __buf[sizeof(_Vp)]; + _Vp* __exp = ::new((void*)__buf) _Vp(__e); + __atomic_impl::__clear_padding(*__exp); + if (__atomic_compare_exchange(std::__addressof(__val), __exp, + __atomic_impl::__clear_padding(__i), + __weak, int(__s), int(__f))) + return true; + __builtin_memcpy(std::__addressof(__e), __exp, sizeof(_Vp)); + return false; + } + else + return __atomic_compare_exchange(std::__addressof(__val), + std::__addressof(__e), + std::__addressof(__i), + __weak, int(__s), int(__f)); + } + } // namespace __atomic_impl - // As above, but for difference_type arguments. +#if __cplusplus > 201703L + // Implementation details of atomic_ref and atomic. + namespace __atomic_impl + { + // Like _Val above, but for difference_type arguments. template using _Diff = __conditional_t, ptrdiff_t, _Val<_Tp>>; @@ -979,7 +1037,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template _GLIBCXX_ALWAYS_INLINE void store(_Tp* __ptr, _Val<_Tp> __t, memory_order __m) noexcept - { __atomic_store(__ptr, std::__addressof(__t), int(__m)); } + { + __atomic_store(__ptr, __atomic_impl::__clear_padding(__t), int(__m)); + } template _GLIBCXX_ALWAYS_INLINE _Val<_Tp> @@ -997,7 +1057,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { alignas(_Tp) unsigned char __buf[sizeof(_Tp)]; auto* __dest = reinterpret_cast<_Val<_Tp>*>(__buf); - __atomic_exchange(__ptr, std::__addressof(__desired), __dest, int(__m)); + __atomic_exchange(__ptr, __atomic_impl::__clear_padding(__desired), + __dest, int(__m)); return *__dest; } @@ -1007,11 +1068,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Val<_Tp> __desired, memory_order __success, memory_order __failure) noexcept { - __glibcxx_assert(__is_valid_cmpexch_failure_order(__failure)); - - return __atomic_compare_exchange(__ptr, std::__addressof(__expected), - std::__addressof(__desired), true, - int(__success), int(__failure)); + return __atomic_impl::__compare_exchange(*__ptr, __expected, __desired, + true, __success, __failure); } template @@ -1020,11 +1078,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Val<_Tp> __desired, memory_order __success, memory_order __failure) noexcept { - __glibcxx_assert(__is_valid_cmpexch_failure_order(__failure)); - - return __atomic_compare_exchange(__ptr, std::__addressof(__expected), - std::__addressof(__desired), false, - int(__success), int(__failure)); + return __atomic_impl::__compare_exchange(*__ptr, __expected, __desired, + false, __success, __failure); } #if __cpp_lib_atomic_wait @@ -1955,9 +2010,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION _Tp** _M_ptr; }; +#endif // C++2a /// @endcond -#endif // C++2a /// @} group atomics diff --git a/libstdc++-v3/include/std/atomic b/libstdc++-v3/include/std/atomic index 70055b8..b913960 100644 --- a/libstdc++-v3/include/std/atomic +++ b/libstdc++-v3/include/std/atomic @@ -230,7 +230,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION atomic& operator=(const atomic&) = delete; atomic& operator=(const atomic&) volatile = delete; - constexpr atomic(_Tp __i) noexcept : _M_i(__i) { } + constexpr atomic(_Tp __i) noexcept : _M_i(__i) + { +#if __cplusplus >= 201402L && __has_builtin(__builtin_clear_padding) + if _GLIBCXX17_CONSTEXPR (__atomic_impl::__maybe_has_padding<_Tp>()) + __builtin_clear_padding(std::__addressof(_M_i)); +#endif + } operator _Tp() const noexcept { return load(); } @@ -270,13 +276,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION void store(_Tp __i, memory_order __m = memory_order_seq_cst) noexcept { - __atomic_store(std::__addressof(_M_i), std::__addressof(__i), int(__m)); + __atomic_store(std::__addressof(_M_i), + __atomic_impl::__clear_padding(__i), + int(__m)); } void store(_Tp __i, memory_order __m = memory_order_seq_cst) volatile noexcept { - __atomic_store(std::__addressof(_M_i), std::__addressof(__i), int(__m)); + __atomic_store(std::__addressof(_M_i), + __atomic_impl::__clear_padding(__i), + int(__m)); } _Tp @@ -302,7 +312,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { alignas(_Tp) unsigned char __buf[sizeof(_Tp)]; _Tp* __ptr = reinterpret_cast<_Tp*>(__buf); - __atomic_exchange(std::__addressof(_M_i), std::__addressof(__i), + __atomic_exchange(std::__addressof(_M_i), + __atomic_impl::__clear_padding(__i), __ptr, int(__m)); return *__ptr; } @@ -313,7 +324,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { alignas(_Tp) unsigned char __buf[sizeof(_Tp)]; _Tp* __ptr = reinterpret_cast<_Tp*>(__buf); - __atomic_exchange(std::__addressof(_M_i), std::__addressof(__i), + __atomic_exchange(std::__addressof(_M_i), + __atomic_impl::__clear_padding(__i), __ptr, int(__m)); return *__ptr; } @@ -322,24 +334,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION compare_exchange_weak(_Tp& __e, _Tp __i, memory_order __s, memory_order __f) noexcept { - __glibcxx_assert(__is_valid_cmpexch_failure_order(__f)); - - return __atomic_compare_exchange(std::__addressof(_M_i), - std::__addressof(__e), - std::__addressof(__i), - true, int(__s), int(__f)); + return __atomic_impl::__compare_exchange(_M_i, __e, __i, true, + __s, __f); } bool compare_exchange_weak(_Tp& __e, _Tp __i, memory_order __s, memory_order __f) volatile noexcept { - __glibcxx_assert(__is_valid_cmpexch_failure_order(__f)); - - return __atomic_compare_exchange(std::__addressof(_M_i), - std::__addressof(__e), - std::__addressof(__i), - true, int(__s), int(__f)); + return __atomic_impl::__compare_exchange(_M_i, __e, __i, true, + __s, __f); } bool @@ -358,24 +362,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION compare_exchange_strong(_Tp& __e, _Tp __i, memory_order __s, memory_order __f) noexcept { - __glibcxx_assert(__is_valid_cmpexch_failure_order(__f)); - - return __atomic_compare_exchange(std::__addressof(_M_i), - std::__addressof(__e), - std::__addressof(__i), - false, int(__s), int(__f)); + return __atomic_impl::__compare_exchange(_M_i, __e, __i, false, + __s, __f); } bool compare_exchange_strong(_Tp& __e, _Tp __i, memory_order __s, memory_order __f) volatile noexcept { - __glibcxx_assert(__is_valid_cmpexch_failure_order(__f)); - - return __atomic_compare_exchange(std::__addressof(_M_i), - std::__addressof(__e), - std::__addressof(__i), - false, int(__s), int(__f)); + return __atomic_impl::__compare_exchange(_M_i, __e, __i, false, + __s, __f); } bool @@ -390,7 +386,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return compare_exchange_strong(__e, __i, __m, __cmpexch_failure_order(__m)); } -#if __cpp_lib_atomic_wait +#if __cpp_lib_atomic_wait void wait(_Tp __old, memory_order __m = memory_order_seq_cst) const noexcept { @@ -407,7 +403,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION void notify_all() noexcept { std::__atomic_notify_address(&_M_i, true); } -#endif // __cpp_lib_atomic_wait +#endif // __cpp_lib_atomic_wait }; #undef _GLIBCXX20_INIT diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/compare_exchange_padding.cc b/libstdc++-v3/testsuite/29_atomics/atomic/compare_exchange_padding.cc new file mode 100644 index 0000000..c4ab876 --- /dev/null +++ b/libstdc++-v3/testsuite/29_atomics/atomic/compare_exchange_padding.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++20" } +// { dg-do run { target c++20 } } +// { dg-add-options libatomic } + +#include + +#include + +struct S { char c; short s; }; + +void __attribute__((noinline,noipa)) +fill_struct(S& s) +{ __builtin_memset(&s, 0xff, sizeof(S)); } + +bool +compare_struct(const S& a, const S& b) +{ return __builtin_memcmp(&a, &b, sizeof(S)) == 0; } + +int +main () +{ + S s; + fill_struct(s); + s.c = 'a'; + s.s = 42; + + std::atomic as{ s }; + auto ts = as.load(); + VERIFY( !compare_struct(s, ts) ); // padding cleared on construction + as.exchange(s); + auto es = as.load(); + VERIFY( compare_struct(ts, es) ); // padding cleared on exchange + + S n; + fill_struct(n); + n.c = 'b'; + n.s = 71; + // padding cleared on compexchg + VERIFY( as.compare_exchange_weak(s, n) ); + VERIFY( as.compare_exchange_strong(n, s) ); + return 0; +} diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_ref/compare_exchange_padding.cc b/libstdc++-v3/testsuite/29_atomics/atomic_ref/compare_exchange_padding.cc new file mode 100644 index 0000000..1b1a12d --- /dev/null +++ b/libstdc++-v3/testsuite/29_atomics/atomic_ref/compare_exchange_padding.cc @@ -0,0 +1,43 @@ +// { dg-options "-std=gnu++20" } +// { dg-do run { target c++20 } } +// { dg-add-options libatomic } + +#include + +#include + +struct S { char c; short s; }; + +void __attribute__((noinline,noipa)) +fill_struct(S& s) +{ __builtin_memset(&s, 0xff, sizeof(S)); } + +bool +compare_struct(const S& a, const S& b) +{ return __builtin_memcmp(&a, &b, sizeof(S)) == 0; } + +int +main () +{ + S s; + fill_struct(s); + s.c = 'a'; + s.s = 42; + + S ss{ s }; + std::atomic_ref as{ s }; + auto ts = as.load(); + VERIFY( !compare_struct(ss, ts) ); // padding cleared on construction + as.exchange(ss); + auto es = as.load(); + VERIFY( compare_struct(ts, es) ); // padding cleared on exchange + + S n; + fill_struct(n); + n.c = 'b'; + n.s = 71; + // padding cleared on compexchg + VERIFY( as.compare_exchange_weak(s, n) ); + VERIFY( as.compare_exchange_strong(n, s) ); + return 0; +} -- cgit v1.1 From 4977507e329ee3ed410fc7338b9aaada81b68361 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Thu, 8 Sep 2022 13:46:02 +0100 Subject: libstdc++: Add always_inline attribute to std::byte operators libstdc++-v3/ChangeLog: * include/c_global/cstddef (byte): Add always_inline attribute to all operator overloads. (to_integer): Add always_inline attribute. --- libstdc++-v3/include/c_global/cstddef | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'libstdc++-v3') diff --git a/libstdc++-v3/include/c_global/cstddef b/libstdc++-v3/include/c_global/cstddef index 4970c2d..df2d88a 100644 --- a/libstdc++-v3/include/c_global/cstddef +++ b/libstdc++-v3/include/c_global/cstddef @@ -119,55 +119,66 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION using __byte_op_t = typename __byte_operand<_IntegerType>::__type; template + [[__gnu__::__always_inline__]] constexpr __byte_op_t<_IntegerType> operator<<(byte __b, _IntegerType __shift) noexcept { return (byte)(unsigned char)((unsigned)__b << __shift); } template + [[__gnu__::__always_inline__]] constexpr __byte_op_t<_IntegerType> operator>>(byte __b, _IntegerType __shift) noexcept { return (byte)(unsigned char)((unsigned)__b >> __shift); } + [[__gnu__::__always_inline__]] constexpr byte operator|(byte __l, byte __r) noexcept { return (byte)(unsigned char)((unsigned)__l | (unsigned)__r); } + [[__gnu__::__always_inline__]] constexpr byte operator&(byte __l, byte __r) noexcept { return (byte)(unsigned char)((unsigned)__l & (unsigned)__r); } + [[__gnu__::__always_inline__]] constexpr byte operator^(byte __l, byte __r) noexcept { return (byte)(unsigned char)((unsigned)__l ^ (unsigned)__r); } + [[__gnu__::__always_inline__]] constexpr byte operator~(byte __b) noexcept { return (byte)(unsigned char)~(unsigned)__b; } template + [[__gnu__::__always_inline__]] constexpr __byte_op_t<_IntegerType>& operator<<=(byte& __b, _IntegerType __shift) noexcept { return __b = __b << __shift; } template + [[__gnu__::__always_inline__]] constexpr __byte_op_t<_IntegerType>& operator>>=(byte& __b, _IntegerType __shift) noexcept { return __b = __b >> __shift; } + [[__gnu__::__always_inline__]] constexpr byte& operator|=(byte& __l, byte __r) noexcept { return __l = __l | __r; } + [[__gnu__::__always_inline__]] constexpr byte& operator&=(byte& __l, byte __r) noexcept { return __l = __l & __r; } + [[__gnu__::__always_inline__]] constexpr byte& operator^=(byte& __l, byte __r) noexcept { return __l = __l ^ __r; } template - [[nodiscard]] + [[nodiscard,__gnu__::__always_inline__]] constexpr _IntegerType to_integer(__byte_op_t<_IntegerType> __b) noexcept { return _IntegerType(__b); } -- cgit v1.1 From 30c811f2bac73e63e0b461ba7ed3805b77898798 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Tue, 6 Sep 2022 13:21:09 +0100 Subject: c++: Fix type completeness checks for type traits [PR106838] The check_trait_type function is used for a number of different type traits that have different requirements on their arguments. For example, __is_constructible allows arrays of unknown bound even if the array element is an incomplete type, but __is_aggregate does not, it always requires the array element type to be complete. Other traits have different requirements again, e.g. __is_empty allows incomplete unions, and arrays (of known or unknown bound) of incomplete types. This alters the check_trait_type function to take an additional KIND parameter which indicates which set of type trait requirements to check. As noted in a comment, the requirements for __is_aggregate deviate from the ones for std::is_aggregate in the standard. It's not necessary for the elements of an array to be complete types, because arrays are always aggregates. The type_has_virtual_destructor change is needed to avoid an ICE. Previously it could never be called for incomplete union types as they were (incorrectly) rejected by check_trait_type. This change causes some additional diagnostics in some libstdc++ tests, where the front end was not previously complaining about invalid types that the library assertions diagnosed. We should consider removing the library assertions from traits where the front end implements the correct checks now. PR c++/106838 gcc/cp/ChangeLog: * class.cc (type_has_virtual_destructor): Return false for union types. * semantics.cc (check_trait_type): Add KIND parameter to support different sets of requirements. (finish_trait_expr): Pass KIND argument for relevant traits. gcc/ChangeLog: * doc/extend.texi (Type Traits): Fix requirements. Document __is_aggregate and __is_final. gcc/testsuite/ChangeLog: * g++.dg/ext/array4.C: Fix invalid use of __is_constructible. * g++.dg/ext/unary_trait_incomplete.C: Fix tests for traits with different requirements. libstdc++-v3/ChangeLog: * testsuite/20_util/is_complete_or_unbounded/memoization_neg.cc: Prune additional errors from front-end. * testsuite/20_util/is_move_constructible/incomplete_neg.cc: Likewise. * testsuite/20_util/is_nothrow_swappable/incomplete_neg.cc: Likewise. * testsuite/20_util/is_nothrow_swappable_with/incomplete_neg.cc: Likewise. * testsuite/20_util/is_swappable_with/incomplete_neg.cc: Likewise. --- .../testsuite/20_util/is_complete_or_unbounded/memoization_neg.cc | 2 ++ libstdc++-v3/testsuite/20_util/is_move_constructible/incomplete_neg.cc | 1 + libstdc++-v3/testsuite/20_util/is_nothrow_swappable/incomplete_neg.cc | 1 + .../testsuite/20_util/is_nothrow_swappable_with/incomplete_neg.cc | 1 + libstdc++-v3/testsuite/20_util/is_swappable_with/incomplete_neg.cc | 1 + 5 files changed, 6 insertions(+) (limited to 'libstdc++-v3') diff --git a/libstdc++-v3/testsuite/20_util/is_complete_or_unbounded/memoization_neg.cc b/libstdc++-v3/testsuite/20_util/is_complete_or_unbounded/memoization_neg.cc index 1870e50..fc0b70b 100644 --- a/libstdc++-v3/testsuite/20_util/is_complete_or_unbounded/memoization_neg.cc +++ b/libstdc++-v3/testsuite/20_util/is_complete_or_unbounded/memoization_neg.cc @@ -1,5 +1,7 @@ // { dg-do compile { target c++11 } } // { dg-prune-output "must be a complete" } +// { dg-prune-output "'value' is not a member of 'std::is_move_cons" } +// { dg-prune-output "invalid use of incomplete type" } // Copyright (C) 2019-2022 Free Software Foundation, Inc. // diff --git a/libstdc++-v3/testsuite/20_util/is_move_constructible/incomplete_neg.cc b/libstdc++-v3/testsuite/20_util/is_move_constructible/incomplete_neg.cc index 7bd453d..7c34b5f 100644 --- a/libstdc++-v3/testsuite/20_util/is_move_constructible/incomplete_neg.cc +++ b/libstdc++-v3/testsuite/20_util/is_move_constructible/incomplete_neg.cc @@ -18,6 +18,7 @@ // . // { dg-error "must be a complete class" "" { target *-*-* } 0 } +// { dg-prune-output "invalid use of incomplete type" } #include diff --git a/libstdc++-v3/testsuite/20_util/is_nothrow_swappable/incomplete_neg.cc b/libstdc++-v3/testsuite/20_util/is_nothrow_swappable/incomplete_neg.cc index 88c9c01..d3a34cc 100644 --- a/libstdc++-v3/testsuite/20_util/is_nothrow_swappable/incomplete_neg.cc +++ b/libstdc++-v3/testsuite/20_util/is_nothrow_swappable/incomplete_neg.cc @@ -18,6 +18,7 @@ // . // { dg-error "must be a complete class" "" { target *-*-* } 0 } +// { dg-prune-output "invalid use of incomplete type" } #include diff --git a/libstdc++-v3/testsuite/20_util/is_nothrow_swappable_with/incomplete_neg.cc b/libstdc++-v3/testsuite/20_util/is_nothrow_swappable_with/incomplete_neg.cc index da0f771..6dfa336 100644 --- a/libstdc++-v3/testsuite/20_util/is_nothrow_swappable_with/incomplete_neg.cc +++ b/libstdc++-v3/testsuite/20_util/is_nothrow_swappable_with/incomplete_neg.cc @@ -18,6 +18,7 @@ // . // { dg-error "must be a complete class" "" { target *-*-* } 0 } +// { dg-prune-output "invalid use of incomplete type" } #include diff --git a/libstdc++-v3/testsuite/20_util/is_swappable_with/incomplete_neg.cc b/libstdc++-v3/testsuite/20_util/is_swappable_with/incomplete_neg.cc index 74ad291..d5fa4225 100644 --- a/libstdc++-v3/testsuite/20_util/is_swappable_with/incomplete_neg.cc +++ b/libstdc++-v3/testsuite/20_util/is_swappable_with/incomplete_neg.cc @@ -18,6 +18,7 @@ // . // { dg-error "must be a complete class" "" { target *-*-* } 0 } +// { dg-prune-output "invalid use of incomplete type" } #include -- cgit v1.1 From a0f83501182de68ff038f3c69da549e6c80bb6bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Dumont?= Date: Thu, 8 Sep 2022 06:55:20 +0200 Subject: libstdc++: mallinfo deprecated, use mallinfo2 when glibc => 2.33 glibc mallinfo is now deprecated resulting in make check-performance failure. When glibc => 2.33 prefer mallinfo2. libstdc++-v3/ChangeLog: * testsuite/util/testsuite_performance.h (__gnu_test::MallocInfo): New. (__gnu_test::malloc_info): New, replace mallinfo on current platform supporting it and use mallinfo2 when glibc >= 2.33. --- .../testsuite/util/testsuite_performance.h | 63 +++++++++++----------- 1 file changed, 30 insertions(+), 33 deletions(-) (limited to 'libstdc++-v3') diff --git a/libstdc++-v3/testsuite/util/testsuite_performance.h b/libstdc++-v3/testsuite/util/testsuite_performance.h index 2e05bef..4f8b1ea 100644 --- a/libstdc++-v3/testsuite/util/testsuite_performance.h +++ b/libstdc++-v3/testsuite/util/testsuite_performance.h @@ -36,42 +36,39 @@ #include #if defined (__linux__) || defined (__GLIBC__) -#include -#elif defined (__FreeBSD__) -extern "C" -{ - struct mallinfo - { - int uordblks; - int hblkhd; - }; +#include // For mallinfo. +#endif - struct mallinfo - mallinfo(void) - { - struct mallinfo m = { (((std::size_t) sbrk (0) + 1023) / 1024), 0 }; - return m; - } -} -#elif !defined (__hpux__) -extern "C" +namespace __gnu_test { - struct mallinfo + struct MallocInfo { - int uordblks; - int hblkhd; - }; + MallocInfo() : uordblks(0), hblkhd(0) { } + MallocInfo(std::size_t uordblocks, std::size_t hblockhd) + : uordblks(uordblocks), hblkhd(hblockhd) + { } - struct mallinfo empty = { 0, 0 }; + std::size_t uordblks; + std::size_t hblkhd; + }; - struct mallinfo - mallinfo(void) - { return empty; } -} + MallocInfo + malloc_info() + { +#if defined (__linux__) || defined (__hpux__) || defined (__GLIBC__) +#if __GLIBC__ > 2 || __GLIBC__ == 2 && __GLIBC_MINOR__ >= 33 + struct mallinfo2 mi = mallinfo2(); +#else + struct mallinfo mi = mallinfo(); +#endif + return MallocInfo(mi.uordblks, mi.hblkhd); +#elif defined (__FreeBSD__) + return MallocInfo((((std::size_t) sbrk (0) + 1023) / 1024), 0); +#else + return MallocInfo(); #endif + } -namespace __gnu_test -{ class time_counter { private: @@ -146,8 +143,8 @@ namespace __gnu_test int who; rusage rusage_begin; rusage rusage_end; - struct mallinfo allocation_begin; - struct mallinfo allocation_end; + MallocInfo allocation_begin; + MallocInfo allocation_end; public: resource_counter(int i = RUSAGE_SELF) : who(i) @@ -168,7 +165,7 @@ namespace __gnu_test if (getrusage(who, &rusage_begin) != 0 ) memset(&rusage_begin, 0, sizeof(rusage_begin)); void* p __attribute__((unused)) = malloc(0); // Needed for some implementations. - allocation_begin = mallinfo(); + allocation_begin = malloc_info(); } void @@ -176,7 +173,7 @@ namespace __gnu_test { if (getrusage(who, &rusage_end) != 0 ) memset(&rusage_end, 0, sizeof(rusage_end)); - allocation_end = mallinfo(); + allocation_end = malloc_info(); } int -- cgit v1.1 From 2e7ad70c4abacbd2614358cf057397620d641b0a Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Fri, 9 Sep 2022 00:18:05 +0000 Subject: Daily bump. --- libstdc++-v3/ChangeLog | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) (limited to 'libstdc++-v3') diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 958f6de..5781735 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,63 @@ +2022-09-08 François Dumont + + * testsuite/util/testsuite_performance.h (__gnu_test::MallocInfo): New. + (__gnu_test::malloc_info): New, replace mallinfo on current platform + supporting it and use mallinfo2 when glibc >= 2.33. + +2022-09-08 Jonathan Wakely + + PR c++/106838 + * testsuite/20_util/is_complete_or_unbounded/memoization_neg.cc: + Prune additional errors from front-end. + * testsuite/20_util/is_move_constructible/incomplete_neg.cc: + Likewise. + * testsuite/20_util/is_nothrow_swappable/incomplete_neg.cc: + Likewise. + * testsuite/20_util/is_nothrow_swappable_with/incomplete_neg.cc: + Likewise. + * testsuite/20_util/is_swappable_with/incomplete_neg.cc: + Likewise. + +2022-09-08 Jonathan Wakely + + * include/c_global/cstddef (byte): Add always_inline attribute + to all operator overloads. + (to_integer): Add always_inline attribute. + +2022-09-08 Thomas Rodgers + Jakub Jelinek + Jonathan Wakely + + * include/bits/atomic_base.h (__atomic_impl::__maybe_has_padding): + New function. + (__atomic_impl::clear_padding): Likewise. + (__atomic_impl::__compare_exchange): Likewise. + (__atomic_impl::compare_exchange_weak): Delegate to + __compare_exchange. + (__atomic_impl::compare_exchange_strong): Likewise. + * include/std/atomic (atomic::atomic(T)): Clear padding when + possible in a constexpr function. + (atomic::store): Clear padding. + (atomic::exchange): Likewise. + (atomic::compare_exchange_weak): Use __compare_exchange. + (atomic::compare_exchange_strong): Likewise. + * testsuite/29_atomics/atomic/compare_exchange_padding.cc: New + test. + * testsuite/29_atomics/atomic_ref/compare_exchange_padding.cc: + New test. + +2022-09-08 Jonathan Wakely + + * include/std/system_error (__adl_only::make_error_code): Add + deleted function. + (__adl_only::make_error_condition): Likewise. + (error_code::error_code(ErrorCodeEnum)): Add using-declaration + for deleted function. + (error_condition::error_condition(ErrorConditionEnum)): + Likewise. + * testsuite/19_diagnostics/error_code/cons/lwg3629.cc: New test. + * testsuite/19_diagnostics/error_condition/cons/lwg3629.cc: New test. + 2022-09-07 Jonathan Wakely * include/std/barrier: Add missing runtime exception. -- cgit v1.1 From 718a6d475b3d17759618c68331c85f55c58ec9a3 Mon Sep 17 00:00:00 2001 From: Patrick Palka Date: Fri, 9 Sep 2022 14:56:32 -0400 Subject: libstdc++: Fix zip_view's operator- for integer-class difference type [PR106766] The difference type of an underlying iterator could be an integer-class type, which make_unsigned_t doesn't handle, so we need to use the more general __make_unsigned_like_t / __to_unsigned_like here instead. PR libstdc++/106766 libstdc++-v3/ChangeLog: * include/std/ranges (zip_view::_Iterator::operator-): Use __to_unsigned_like instead of make_unsigned_t. (zip_view::_Sentinel::operator-): Likewise. * testsuite/std/ranges/zip/1.cc (test04): New test. --- libstdc++-v3/include/std/ranges | 8 ++++---- libstdc++-v3/testsuite/std/ranges/zip/1.cc | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) (limited to 'libstdc++-v3') diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges index 2b5cb05..2b8fec3 100644 --- a/libstdc++-v3/include/std/ranges +++ b/libstdc++-v3/include/std/ranges @@ -4657,8 +4657,8 @@ namespace views::__adaptor return ranges::min({difference_type(std::get<_Is>(__x._M_current) - std::get<_Is>(__y._M_current))...}, ranges::less{}, - [](difference_type __i) -> make_unsigned_t { - return __i < 0 ? -__i : __i; + [](difference_type __i) { + return __detail::__to_unsigned_like(__i < 0 ? -__i : __i); }); }(make_index_sequence{}); } @@ -4726,8 +4726,8 @@ namespace views::__adaptor return [&](index_sequence<_Is...>) { return ranges::min({_Ret(std::get<_Is>(__x._M_current) - std::get<_Is>(__y._M_end))...}, ranges::less{}, - [](_Ret __i) -> make_unsigned_t<_Ret> { - return __i < 0 ? -__i : __i; + [](_Ret __i) { + return __detail::__to_unsigned_like(__i < 0 ? -__i : __i); }); }(make_index_sequence{}); } diff --git a/libstdc++-v3/testsuite/std/ranges/zip/1.cc b/libstdc++-v3/testsuite/std/ranges/zip/1.cc index 0113efd..e9e40fb 100644 --- a/libstdc++-v3/testsuite/std/ranges/zip/1.cc +++ b/libstdc++-v3/testsuite/std/ranges/zip/1.cc @@ -102,10 +102,28 @@ test03() return true; } +constexpr bool +test04() +{ + // PR libstdc++/106766 +#if __SIZEOF_INT128__ + auto r = views::zip(views::iota(__int128(0), __int128(1))); +#else + auto r = views::zip(views::iota(0ll, 1ll)); +#endif + auto i = r.begin(); + auto s = r.end(); + VERIFY( s - i == 1 ); + VERIFY( i + 1 - i == 1 ); + + return true; +} + int main() { static_assert(test01()); static_assert(test02()); static_assert(test03()); + static_assert(test04()); } -- cgit v1.1 From e469506b7fdd1bf2c958ca3140573a474fcba3b8 Mon Sep 17 00:00:00 2001 From: Patrick Palka Date: Fri, 9 Sep 2022 14:56:37 -0400 Subject: libstdc++: Fix typo in adjacent_view::_Iterator [PR106798] PR libstdc++/106798 libstdc++-v3/ChangeLog: * include/std/ranges (adjacent_view::_Iterator::_Iterator): Fix typo. * testsuite/std/ranges/adaptors/adjacent/1.cc (test04): New test. --- libstdc++-v3/include/std/ranges | 2 +- libstdc++-v3/testsuite/std/ranges/adaptors/adjacent/1.cc | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'libstdc++-v3') diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges index 2b8fec3..37ad80a 100644 --- a/libstdc++-v3/include/std/ranges +++ b/libstdc++-v3/include/std/ranges @@ -5239,7 +5239,7 @@ namespace views::__adaptor requires _Const && convertible_to, iterator_t<_Base>> { for (size_t __j = 0; __j < _Nm; ++__j) - _M_current[__j] = std::move(__i[__j]); + _M_current[__j] = std::move(__i._M_current[__j]); } constexpr auto diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/adjacent/1.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/adjacent/1.cc index 9829f79..443c1fb 100644 --- a/libstdc++-v3/testsuite/std/ranges/adaptors/adjacent/1.cc +++ b/libstdc++-v3/testsuite/std/ranges/adaptors/adjacent/1.cc @@ -101,10 +101,22 @@ test03() return true; } +constexpr bool +test04() +{ + // PR libstdc++/106798 + auto r = views::single(0) | views::lazy_split(0) | views::pairwise; + decltype(ranges::cend(r)) s = r.end(); + VERIFY( r.begin() == s ); + + return true; +} + int main() { static_assert(test01()); static_assert(test02()); static_assert(test03()); + static_assert(test04()); } -- cgit v1.1 From 8298427f6b546cabb853edd45c009cd1967b9d38 Mon Sep 17 00:00:00 2001 From: Patrick Palka Date: Fri, 9 Sep 2022 14:59:14 -0400 Subject: libstdc++: Fix return type of empty zip_/adjacent_transform [PR106803] PR libstdc++/106803 libstdc++-v3/ChangeLog: * include/std/ranges (views::_ZipTransform::operator()): Correct return type in the empty case. (views::_AdjacentTransform::operator()): Likewise. --- libstdc++-v3/include/std/ranges | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libstdc++-v3') diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges index 37ad80a..20eb4e8 100644 --- a/libstdc++-v3/include/std/ranges +++ b/libstdc++-v3/include/std/ranges @@ -5071,7 +5071,7 @@ namespace views::__adaptor operator() [[nodiscard]] (_Fp&& __f, _Ts&&... __ts) const { if constexpr (sizeof...(_Ts) == 0) - return views::empty>>; + return views::empty&>>>; else return zip_transform_view(std::forward<_Fp>(__f), std::forward<_Ts>(__ts)...); } @@ -5762,7 +5762,7 @@ namespace views::__adaptor operator() [[nodiscard]] (_Range&& __r, _Fp&& __f) const { if constexpr (_Nm == 0) - return views::empty>; + return zip_transform(std::forward<_Fp>(__f)); else return adjacent_transform_view, decay_t<_Fp>, _Nm> (std::forward<_Range>(__r), std::forward<_Fp>(__f)); -- cgit v1.1 From 007680f946eaffa3c6321624129e1ec18e673091 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Fri, 9 Sep 2022 21:03:58 +0100 Subject: libstdc++: Rename parameter to avoid darwin __weak qualifier libstdc++-v3/ChangeLog: * include/bits/atomic_base.h (__atomic_impl::__compare_exchange): Rename __weak to __is_weak. * testsuite/17_intro/names.cc: Add __weak and __strong. --- libstdc++-v3/include/bits/atomic_base.h | 7 ++++--- libstdc++-v3/testsuite/17_intro/names.cc | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'libstdc++-v3') diff --git a/libstdc++-v3/include/bits/atomic_base.h b/libstdc++-v3/include/bits/atomic_base.h index 2931554..6ea3268 100644 --- a/libstdc++-v3/include/bits/atomic_base.h +++ b/libstdc++-v3/include/bits/atomic_base.h @@ -990,7 +990,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template _GLIBCXX_ALWAYS_INLINE bool __compare_exchange(_Tp& __val, _Val<_Tp>& __e, _Val<_Tp>& __i, - bool __weak, memory_order __s, memory_order __f) noexcept + bool __is_weak, + memory_order __s, memory_order __f) noexcept { __glibcxx_assert(__is_valid_cmpexch_failure_order(__f)); @@ -1005,7 +1006,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __atomic_impl::__clear_padding(*__exp); if (__atomic_compare_exchange(std::__addressof(__val), __exp, __atomic_impl::__clear_padding(__i), - __weak, int(__s), int(__f))) + __is_weak, int(__s), int(__f))) return true; __builtin_memcpy(std::__addressof(__e), __exp, sizeof(_Vp)); return false; @@ -1014,7 +1015,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return __atomic_compare_exchange(std::__addressof(__val), std::__addressof(__e), std::__addressof(__i), - __weak, int(__s), int(__f)); + __is_weak, int(__s), int(__f)); } } // namespace __atomic_impl diff --git a/libstdc++-v3/testsuite/17_intro/names.cc b/libstdc++-v3/testsuite/17_intro/names.cc index ede2fe8..86fb8f8 100644 --- a/libstdc++-v3/testsuite/17_intro/names.cc +++ b/libstdc++-v3/testsuite/17_intro/names.cc @@ -129,6 +129,10 @@ // This clashes with newlib so don't use it. # define __lockable cannot be used as an identifier +#ifndef __APPLE__ +#define __weak predefined qualifier on darwin +#define __strong predefined qualifier on darwin +#endif // Common template parameter names #define OutputIterator OutputIterator is not a reserved name -- cgit v1.1 From 861d1a11c0a052ddb3851950d3c0db86b320646d Mon Sep 17 00:00:00 2001 From: GCC Administrator Date: Sat, 10 Sep 2022 00:17:21 +0000 Subject: Daily bump. --- libstdc++-v3/ChangeLog | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'libstdc++-v3') diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 5781735..2e15013 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,31 @@ +2022-09-09 Jonathan Wakely + + * include/bits/atomic_base.h (__atomic_impl::__compare_exchange): + Rename __weak to __is_weak. + * testsuite/17_intro/names.cc: Add __weak and __strong. + +2022-09-09 Patrick Palka + + PR libstdc++/106803 + * include/std/ranges (views::_ZipTransform::operator()): Correct + return type in the empty case. + (views::_AdjacentTransform::operator()): Likewise. + +2022-09-09 Patrick Palka + + PR libstdc++/106798 + * include/std/ranges (adjacent_view::_Iterator::_Iterator): Fix + typo. + * testsuite/std/ranges/adaptors/adjacent/1.cc (test04): New test. + +2022-09-09 Patrick Palka + + PR libstdc++/106766 + * include/std/ranges (zip_view::_Iterator::operator-): Use + __to_unsigned_like instead of make_unsigned_t. + (zip_view::_Sentinel::operator-): Likewise. + * testsuite/std/ranges/zip/1.cc (test04): New test. + 2022-09-08 François Dumont * testsuite/util/testsuite_performance.h (__gnu_test::MallocInfo): New. -- cgit v1.1