[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gcc-bugs
Subject:    libstdc++/3018: bug in std_bitset.h for bitset<>::test method
From:       brendan () zen ! org
Date:       2001-05-31 21:58:31
[Download RAW message or body]


> Number:         3018
> Category:       libstdc++
> Synopsis:       bug in std_bitset.h for bitset<>::test method
> Confidential:   no
> Severity:       serious
> Priority:       medium
> Responsible:    unassigned
> State:          open
> Class:          sw-bug
> Submitter-Id:   net
> Arrival-Date:   Thu May 31 15:06:03 PDT 2001
> Closed-Date:
> Last-Modified:
> Originator:     brendan@zen.org
> Release:        egcs3 branch
> Organization:
> Environment:

> Description:
Attached is a tweak to fix the test() method in the bitset template class.  The \
comparison should be looking at pos being >= the number of bits, not just > the \
number.

Hope this helps,
B
> How-To-Repeat:

> Fix:

> Release-Note:
> Audit-Trail:
> Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="diffs-bitset.txt"
Content-Disposition: inline; filename="diffs-bitset.txt"

2001-05-31  Brendan Kehoe  <brendan@zen.org>

	* include/bits/std_bitset.h (bitset::test): Fix comparison to
	check __pos >= _Nb, since __pos also cannot be == _Nb given that
	the bits are values 0 to _Nb-1, not 0 to _Nb.

Index: std_bitset.h
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/include/bits/std_bitset.h,v
retrieving revision 1.3.6.2
diff -u -p -r1.3.6.2 std_bitset.h
--- std_bitset.h	2001/05/14 19:49:03	1.3.6.2
+++ std_bitset.h	2001/05/31 21:52:15
@@ -629,7 +629,7 @@ public:
   }
 
   bool test(size_t __pos) const {
-    if (__pos > _Nb)
+    if (__pos >= _Nb)
       __STL_THROW(out_of_range("bitset"));
 
     return _Unchecked_test(__pos);


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic