aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2010-09-18 01:29:31 +0000
committerpaolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4>2010-09-18 01:29:31 +0000
commit779871ac4aa150e56adb4556dcf17459368b3178 (patch)
treec0307de0de4cf2d8e1498c3c23ee0401553757f7
parentea07cad99a8d91b699e0726495a386b74ba6c759 (diff)
2010-09-17 Luc Hermitte <hermitte@free.fr>
Paolo Carlini <paolo.carlini@oracle.com> PR libstdc++/45713 * include/std/bitset: Fix _GLIBCXX_BITSET_WORDS macro. * testsuite/23_containers/bitset/45713.cc: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@164388 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libstdc++-v3/ChangeLog7
-rw-r--r--libstdc++-v3/include/std/bitset4
-rw-r--r--libstdc++-v3/testsuite/23_containers/bitset/45713.cc25
3 files changed, 34 insertions, 2 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index aa9d6249248..f74e54f02ed 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,10 @@
+2010-09-17 Luc Hermitte <hermitte@free.fr>
+ Paolo Carlini <paolo.carlini@oracle.com>
+
+ PR libstdc++/45713
+ * include/std/bitset: Fix _GLIBCXX_BITSET_WORDS macro.
+ * testsuite/23_containers/bitset/45713.cc: New.
+
2010-09-16 Paolo Carlini <paolo.carlini@oracle.com>
* include/bits/stl_raw_storage_iter.h (raw_storage_iterator<>::
diff --git a/libstdc++-v3/include/std/bitset b/libstdc++-v3/include/std/bitset
index 909ed770735..6fe1235ee89 100644
--- a/libstdc++-v3/include/std/bitset
+++ b/libstdc++-v3/include/std/bitset
@@ -53,8 +53,8 @@
#define _GLIBCXX_BITSET_BITS_PER_WORD (__CHAR_BIT__ * sizeof(unsigned long))
#define _GLIBCXX_BITSET_WORDS(__n) \
- ((__n) < 1 ? 0 : ((__n) + _GLIBCXX_BITSET_BITS_PER_WORD - 1) \
- / _GLIBCXX_BITSET_BITS_PER_WORD)
+ ((__n) / _GLIBCXX_BITSET_BITS_PER_WORD + \
+ ((__n) % _GLIBCXX_BITSET_BITS_PER_WORD == 0 ? 0 : 1))
_GLIBCXX_BEGIN_NESTED_NAMESPACE(std, _GLIBCXX_STD_D)
diff --git a/libstdc++-v3/testsuite/23_containers/bitset/45713.cc b/libstdc++-v3/testsuite/23_containers/bitset/45713.cc
new file mode 100644
index 00000000000..8d369d63e18
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/bitset/45713.cc
@@ -0,0 +1,25 @@
+// Copyright (C) 2010 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// 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
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do compile }
+
+#include <bitset>
+
+// libstdc++/45713
+#if __SIZEOF_SIZE_T__ >= 4
+int test[sizeof(std::bitset<0xffffffff>) != 1 ? 1 : -1];
+#endif