public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: libstdc++/4533: mistaken assumption in find_first_not_of and find_last_not_of
@ 2001-10-20 19:03 rodrigc
0 siblings, 0 replies; 2+ messages in thread
From: rodrigc @ 2001-10-20 19:03 UTC (permalink / raw)
To: brendan, gcc-bugs, gcc-prs, nobody
Synopsis: mistaken assumption in find_first_not_of and find_last_not_of
State-Changed-From-To: open->closed
State-Changed-By: rodrigc
State-Changed-When: Sat Oct 20 19:03:20 2001
State-Changed-Why:
Patch applied.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=4533&database=gcc
^ permalink raw reply [flat|nested] 2+ messages in thread
* libstdc++/4533: mistaken assumption in find_first_not_of and find_last_not_of
@ 2001-10-11 5:26 brendan
0 siblings, 0 replies; 2+ messages in thread
From: brendan @ 2001-10-11 5:26 UTC (permalink / raw)
To: gcc-gnats
>Number: 4533
>Category: libstdc++
>Synopsis: mistaken assumption in find_first_not_of and find_last_not_of
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Oct 11 05:26:24 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: Brendan Kehoe
>Release: CVS tree
>Organization:
>Environment:
>Description:
In bits/basic_string.tcc, the function find_first_not_of includes a check in its for loop making sure the size specified in the third argument is non-zero. The standard doesn't actually say it's invalid to have a zero-width size. Thus we should be getting __pos back, not npos.
Similarly, the same goes with find_last_not_of.
>How-To-Repeat:
>Fix:
Take out `__n &&' from find_first_not_of.
Take out `&& __n' from find_last_not_of.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="diffs-basic_string-1.txt"
Content-Disposition: inline; filename="diffs-basic_string-1.txt"
2001-10-10 Brendan Kehoe <brendan@zen.org>
* bits/basic_string.tcc (find_first_not_of): Take out check for
__n being non-zero, since the standard does not mandate that.
e.g., a search for "" in "" should yield position 0, not npos.
(find_last_not_of): Likewise.
Index: include/bits/basic_string.tcc
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/include/bits/basic_string.tcc,v
retrieving revision 1.6
diff -u -p -r1.6 basic_string.tcc
--- basic_string.tcc 2001/07/20 00:09:31 1.6
+++ basic_string.tcc 2001/10/10 11:44:12
@@ -698,7 +698,7 @@ namespace std
find_first_not_of(const _CharT* __s, size_type __pos, size_type __n) const
{
size_t __xpos = __pos;
- for (; __n && __xpos < this->size(); ++__xpos)
+ for (; __xpos < this->size(); ++__xpos)
if (!traits_type::find(__s, __n, _M_data()[__xpos]))
return __xpos;
return npos;
@@ -722,7 +722,7 @@ namespace std
find_last_not_of(const _CharT* __s, size_type __pos, size_type __n) const
{
size_type __size = this->size();
- if (__size && __n)
+ if (__size)
{
if (--__size > __pos)
__size = __pos;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2001-10-20 19:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-20 19:03 libstdc++/4533: mistaken assumption in find_first_not_of and find_last_not_of rodrigc
-- strict thread matches above, loose matches on Subject: below --
2001-10-11 5:26 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).