This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[v3] Fix libstdc++/15361
- From: Paolo Carlini <pcarlini at suse dot de>
- To: "'gcc-patches at gcc dot gnu dot org'" <gcc-patches at gcc dot gnu dot org>
- Cc: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Fri, 14 May 2004 18:54:07 +0200
- Subject: [v3] Fix libstdc++/15361
Hi,
it seems to me that the safest and correct thing to do here is
simply restoring the original HP/SGI code, used in 3.3.
This is a (minor) 3.4/3.5 regression and I will apply the fix to
the release branch too.
Tested x86-linux.
Paolo.
///////////
2004-05-14 Paolo Carlini <pcarlini@suse.de>
Ivan Godard <igodard@pacbell.net>
PR libstdc++/15361
* include/std/std_bitset.h (_Base_bitset<_Nw>::_M_do_find_next): Fix.
* testsuite/23_containers/bitset/ext/15361.cc: New.
diff -urN libstdc++-v3-orig/include/std/std_bitset.h libstdc++-v3/include/std/std_bitset.h
--- libstdc++-v3-orig/include/std/std_bitset.h 2004-04-16 21:04:05.000000000 +0200
+++ libstdc++-v3/include/std/std_bitset.h 2004-05-14 18:14:36.000000000 +0200
@@ -1,6 +1,6 @@
// <bitset> -*- C++ -*-
-// Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
+// Copyright (C) 2001, 2002, 2003, 2004 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
@@ -290,7 +290,7 @@
++__prev;
// check out of bounds
- if ( __prev >= _Nw * _GLIBCXX_BITSET_BITS_PER_WORD )
+ if (__prev >= _Nw * _GLIBCXX_BITSET_BITS_PER_WORD)
return __not_found;
// search first word
@@ -298,7 +298,7 @@
_WordT __thisword = _M_w[__i];
// mask off bits below bound
- __thisword >>= __prev + 1;
+ __thisword &= (~static_cast<_WordT>(0)) << _S_whichbit(__prev);
if (__thisword != static_cast<_WordT>(0))
return __i * _GLIBCXX_BITSET_BITS_PER_WORD
diff -urN libstdc++-v3-orig/testsuite/23_containers/bitset/ext/15361.cc libstdc++-v3/testsuite/23_containers/bitset/ext/15361.cc
--- libstdc++-v3-orig/testsuite/23_containers/bitset/ext/15361.cc 1970-01-01 01:00:00.000000000 +0100
+++ libstdc++-v3/testsuite/23_containers/bitset/ext/15361.cc 2004-05-14 18:43:21.000000000 +0200
@@ -0,0 +1,40 @@
+// Copyright (C) 2004 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 2, 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 COPYING. If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+
+#include <bitset>
+#include <testsuite_hooks.h>
+
+// libstdc++/15361
+void test01()
+{
+ using namespace std;
+ bool test __attribute__((unused)) = true;
+
+ bitset<256> b;
+ b.set(225);
+ b.set(226);
+
+ VERIFY( b._Find_first() == 225 );
+ VERIFY( b._Find_next(225) == 226 );
+}
+
+int main()
+{
+ test01();
+ return 0;
+}