From patchwork Tue Nov 6 10:45:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [v3] A couple of small fixes Date: Tue, 06 Nov 2012 00:45:45 -0000 From: Paolo Carlini X-Patchwork-Id: 197459 Message-Id: <5098EA59.8010807@oracle.com> To: "gcc-patches@gcc.gnu.org" Cc: libstdc++ Hi, for issues I noticed while working on debug-mode for std::array: avoid the inclusion of in two places (in v3 we never include it); fix the new check added by Florian vs -fno-exceptions. Tested x86_64-linux. Thanks, Paolo. /////////////////////// 2012-11-06 Paolo Carlini * include/bits/atomic_base.h: Don't include , use nullptr. * include/std/atomic: Likewise. * include/tr2/dynamic_bitset: Likewise. * libsupc++/vec.cc (compute_size(std::size_t, std::size_t, std::size_t)): Fix for -fno-exceptions. Index: include/bits/atomic_base.h =================================================================== --- include/bits/atomic_base.h (revision 193210) +++ include/bits/atomic_base.h (working copy) @@ -1,6 +1,6 @@ // -*- C++ -*- header. -// Copyright (C) 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. +// Copyright (C) 2008-2012 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -35,7 +35,6 @@ #include #include #include -#include #include namespace std _GLIBCXX_VISIBILITY(default) @@ -423,11 +422,11 @@ bool is_lock_free() const noexcept - { return __atomic_is_lock_free(sizeof(_M_i), NULL); } + { return __atomic_is_lock_free(sizeof(_M_i), nullptr); } bool is_lock_free() const volatile noexcept - { return __atomic_is_lock_free(sizeof(_M_i), NULL); } + { return __atomic_is_lock_free(sizeof(_M_i), nullptr); } void store(__int_type __i, memory_order __m = memory_order_seq_cst) noexcept @@ -717,11 +716,11 @@ bool is_lock_free() const noexcept - { return __atomic_is_lock_free(_M_type_size(1), NULL); } + { return __atomic_is_lock_free(_M_type_size(1), nullptr); } bool is_lock_free() const volatile noexcept - { return __atomic_is_lock_free(_M_type_size(1), NULL); } + { return __atomic_is_lock_free(_M_type_size(1), nullptr); } void store(__pointer_type __p, Index: include/std/atomic =================================================================== --- include/std/atomic (revision 193210) +++ include/std/atomic (working copy) @@ -1,6 +1,6 @@ // -*- C++ -*- header. -// Copyright (C) 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. +// Copyright (C) 2008-2012 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -184,11 +184,11 @@ bool is_lock_free() const noexcept - { return __atomic_is_lock_free(sizeof(_M_i), NULL); } + { return __atomic_is_lock_free(sizeof(_M_i), nullptr); } bool is_lock_free() const volatile noexcept - { return __atomic_is_lock_free(sizeof(_M_i), NULL); } + { return __atomic_is_lock_free(sizeof(_M_i), nullptr); } void store(_Tp __i, memory_order _m = memory_order_seq_cst) noexcept Index: include/tr2/dynamic_bitset =================================================================== --- include/tr2/dynamic_bitset (revision 193210) +++ include/tr2/dynamic_bitset (working copy) @@ -33,7 +33,6 @@ #include #include -#include // For size_t #include #include // For std::allocator #include // For invalid_argument, out_of_range, Index: libsupc++/vec.cc =================================================================== --- libsupc++/vec.cc (revision 193210) +++ libsupc++/vec.cc (working copy) @@ -28,6 +28,7 @@ #include #include #include +#include #include #include "unwind-cxx.h" @@ -65,10 +66,18 @@ std::size_t padding_size) { if (element_size && element_count > std::size_t(-1) / element_size) +#ifdef __EXCEPTIONS throw std::bad_alloc(); +#else + std::abort(); +#endif std::size_t size = element_count * element_size; if (size + padding_size < size) +#ifdef __EXCEPTIONS throw std::bad_alloc(); +#else + std::abort(); +#endif return size + padding_size; } }