Patchwork [v3] libstdc++/45713

login
register
mail settings
Submitter Paolo Carlini
Date Sept. 18, 2010, 1:30 a.m.
Message ID <4C94163E.10000@oracle.com>
Download mbox | patch
Permalink /patch/65119/
State New
Headers show

Comments

Paolo Carlini - Sept. 18, 2010, 1:30 a.m.
Hi,

tested x86_64-linux multilib, committed to mainline.

Paolo.

/////////////////////////
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.

Patch

Index: include/std/bitset
===================================================================
--- include/std/bitset	(revision 164368)
+++ include/std/bitset	(working copy)
@@ -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)
 
Index: testsuite/23_containers/bitset/45713.cc
===================================================================
--- testsuite/23_containers/bitset/45713.cc	(revision 0)
+++ testsuite/23_containers/bitset/45713.cc	(revision 0)
@@ -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