public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* libstdc++/3018: bug in std_bitset.h for bitset<>::test method
@ 2001-05-31 15:06 brendan
  0 siblings, 0 replies; only message in thread
From: brendan @ 2001-05-31 15:06 UTC (permalink / raw)
  To: gcc-gnats

>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);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-05-31 15:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-31 15:06 libstdc++/3018: bug in std_bitset.h for bitset<>::test method brendan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).