public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/31401]  New: string find behaves strange when searching from npos
@ 2007-03-30 14:53 Ko dot vanderSloot at uvt dot nl
  2007-03-30 16:26 ` [Bug libstdc++/31401] " pcarlini at suse dot de
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Ko dot vanderSloot at uvt dot nl @ 2007-03-30 14:53 UTC (permalink / raw)
  To: gcc-bugs

the following program demonstrates, what I think, a flaw in std::string find.
According to me and (see comp.lang.c++ and c.l.c++.moderated) many others,
find( "astring", string::npos ) should always return string::npos.
But G++ seems to wrap around an start searching at the begin of the string.

sample program:
#include <iostream>
#include <string>

using namespace std;

int main(){
  string use = "anu";
  string::size_type pos1 = use.find_first_not_of( "an" );
  cerr << "pos1=" << pos1 << endl;
  pos1 = use.find( "a", string::npos );
  if ( pos1 == string::npos )
    cerr << "I expected this" << endl;
  else
    cerr << "problem because pos1=" << pos1 << endl;
  pos1 = use.find( "q", string::npos );
  if ( pos1 == string::npos )
    cerr << "I expected this" << endl;
  else
    cerr << "problem because pos1=" << pos1 << endl;
}


-- 
           Summary: string find behaves strange when searching from npos
           Product: gcc
           Version: 4.1.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: Ko dot vanderSloot at uvt dot nl


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31401


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libstdc++/31401] string find behaves strange when searching from npos
  2007-03-30 14:53 [Bug libstdc++/31401] New: string find behaves strange when searching from npos Ko dot vanderSloot at uvt dot nl
@ 2007-03-30 16:26 ` pcarlini at suse dot de
  2007-03-30 16:52 ` pcarlini at suse dot de
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pcarlini at suse dot de @ 2007-03-30 16:26 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pcarlini at suse dot de  2007-03-30 17:25 -------
Yes, this is stupid bug, it's an unintended behavior caused by unsigned
overflow. Will be fixed before the end of the day, but isn't a regression, thus
only in 4_2-branch and mainline.


-- 

pcarlini at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pcarlini at suse dot de
                   |dot org                     |
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2007-03-30 17:25:41
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31401


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libstdc++/31401] string find behaves strange when searching from npos
  2007-03-30 14:53 [Bug libstdc++/31401] New: string find behaves strange when searching from npos Ko dot vanderSloot at uvt dot nl
  2007-03-30 16:26 ` [Bug libstdc++/31401] " pcarlini at suse dot de
@ 2007-03-30 16:52 ` pcarlini at suse dot de
  2007-03-30 17:11 ` paolo at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pcarlini at suse dot de @ 2007-03-30 16:52 UTC (permalink / raw)
  To: gcc-bugs



-- 

pcarlini at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |4.2.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31401


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libstdc++/31401] string find behaves strange when searching from npos
  2007-03-30 14:53 [Bug libstdc++/31401] New: string find behaves strange when searching from npos Ko dot vanderSloot at uvt dot nl
  2007-03-30 16:26 ` [Bug libstdc++/31401] " pcarlini at suse dot de
  2007-03-30 16:52 ` pcarlini at suse dot de
@ 2007-03-30 17:11 ` paolo at gcc dot gnu dot org
  2007-03-30 17:12 ` paolo at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: paolo at gcc dot gnu dot org @ 2007-03-30 17:11 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from paolo at gcc dot gnu dot org  2007-03-30 18:11 -------
Subject: Bug 31401

Author: paolo
Date: Fri Mar 30 18:10:50 2007
New Revision: 123361

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123361
Log:
2007-03-30  Paolo Carlini  <pcarlini@suse.de>

        PR libstdc++/31401
        * include/bits/basic_string.tcc (find(const _CharT*, size_type,
        size_type)): Avoid unsigned overflow.
        * testsuite/21_strings/basic_string/find/char/4.cc: New.
        * testsuite/21_strings/basic_string/find/wchar_t/4.cc: Likewise.

Added:
    trunk/libstdc++-v3/testsuite/21_strings/basic_string/find/char/4.cc
    trunk/libstdc++-v3/testsuite/21_strings/basic_string/find/wchar_t/4.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/bits/basic_string.tcc


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31401


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libstdc++/31401] string find behaves strange when searching from npos
  2007-03-30 14:53 [Bug libstdc++/31401] New: string find behaves strange when searching from npos Ko dot vanderSloot at uvt dot nl
                   ` (2 preceding siblings ...)
  2007-03-30 17:11 ` paolo at gcc dot gnu dot org
@ 2007-03-30 17:12 ` paolo at gcc dot gnu dot org
  2007-03-30 17:13 ` pcarlini at suse dot de
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: paolo at gcc dot gnu dot org @ 2007-03-30 17:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from paolo at gcc dot gnu dot org  2007-03-30 18:11 -------
Subject: Bug 31401

Author: paolo
Date: Fri Mar 30 18:11:22 2007
New Revision: 123362

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123362
Log:
2007-03-30  Paolo Carlini  <pcarlini@suse.de>

        PR libstdc++/31401
        * include/bits/basic_string.tcc (find(const _CharT*, size_type,
        size_type)): Avoid unsigned overflow.
        * testsuite/21_strings/basic_string/find/char/4.cc: New.
        * testsuite/21_strings/basic_string/find/wchar_t/4.cc: Likewise.

Added:
   
branches/gcc-4_2-branch/libstdc++-v3/testsuite/21_strings/basic_string/find/char/4.cc
   
branches/gcc-4_2-branch/libstdc++-v3/testsuite/21_strings/basic_string/find/wchar_t/4.cc
Modified:
    branches/gcc-4_2-branch/libstdc++-v3/ChangeLog
    branches/gcc-4_2-branch/libstdc++-v3/include/bits/basic_string.tcc


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31401


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libstdc++/31401] string find behaves strange when searching from npos
  2007-03-30 14:53 [Bug libstdc++/31401] New: string find behaves strange when searching from npos Ko dot vanderSloot at uvt dot nl
                   ` (3 preceding siblings ...)
  2007-03-30 17:12 ` paolo at gcc dot gnu dot org
@ 2007-03-30 17:13 ` pcarlini at suse dot de
  2007-04-02 10:09 ` paolo at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pcarlini at suse dot de @ 2007-03-30 17:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from pcarlini at suse dot de  2007-03-30 18:12 -------
Fixed for 4.2.0.


-- 

pcarlini at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31401


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libstdc++/31401] string find behaves strange when searching from npos
  2007-03-30 14:53 [Bug libstdc++/31401] New: string find behaves strange when searching from npos Ko dot vanderSloot at uvt dot nl
                   ` (4 preceding siblings ...)
  2007-03-30 17:13 ` pcarlini at suse dot de
@ 2007-04-02 10:09 ` paolo at gcc dot gnu dot org
  2007-04-02 10:09 ` paolo at gcc dot gnu dot org
  2007-07-11 18:20 ` pcarlini at suse dot de
  7 siblings, 0 replies; 9+ messages in thread
From: paolo at gcc dot gnu dot org @ 2007-04-02 10:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from paolo at gcc dot gnu dot org  2007-04-02 11:09 -------
Subject: Bug 31401

Author: paolo
Date: Mon Apr  2 11:09:07 2007
New Revision: 123423

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123423
Log:
2007-04-02  Paolo Carlini  <pcarlini@suse.de>

        PR libstdc++/31401 (vstring bits)
        * include/ext/vstring.tcc (find(const _CharT*, size_type,
        size_type)): Avoid unsigned overflow.

Modified:
    branches/gcc-4_2-branch/libstdc++-v3/ChangeLog
    branches/gcc-4_2-branch/libstdc++-v3/include/ext/vstring.tcc


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31401


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libstdc++/31401] string find behaves strange when searching from npos
  2007-03-30 14:53 [Bug libstdc++/31401] New: string find behaves strange when searching from npos Ko dot vanderSloot at uvt dot nl
                   ` (5 preceding siblings ...)
  2007-04-02 10:09 ` paolo at gcc dot gnu dot org
@ 2007-04-02 10:09 ` paolo at gcc dot gnu dot org
  2007-07-11 18:20 ` pcarlini at suse dot de
  7 siblings, 0 replies; 9+ messages in thread
From: paolo at gcc dot gnu dot org @ 2007-04-02 10:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from paolo at gcc dot gnu dot org  2007-04-02 11:09 -------
Subject: Bug 31401

Author: paolo
Date: Mon Apr  2 11:08:50 2007
New Revision: 123422

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123422
Log:
2007-04-02  Paolo Carlini  <pcarlini@suse.de>

        PR libstdc++/31401 (vstring bits)
        * include/ext/vstring.tcc (find(const _CharT*, size_type,
        size_type)): Avoid unsigned overflow.

Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/ext/vstring.tcc


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31401


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libstdc++/31401] string find behaves strange when searching from npos
  2007-03-30 14:53 [Bug libstdc++/31401] New: string find behaves strange when searching from npos Ko dot vanderSloot at uvt dot nl
                   ` (6 preceding siblings ...)
  2007-04-02 10:09 ` paolo at gcc dot gnu dot org
@ 2007-07-11 18:20 ` pcarlini at suse dot de
  7 siblings, 0 replies; 9+ messages in thread
From: pcarlini at suse dot de @ 2007-07-11 18:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from pcarlini at suse dot de  2007-07-11 18:20 -------
*** Bug 32730 has been marked as a duplicate of this bug. ***


-- 

pcarlini at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gnu at bluedreamer dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31401


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2007-07-11 18:20 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-30 14:53 [Bug libstdc++/31401] New: string find behaves strange when searching from npos Ko dot vanderSloot at uvt dot nl
2007-03-30 16:26 ` [Bug libstdc++/31401] " pcarlini at suse dot de
2007-03-30 16:52 ` pcarlini at suse dot de
2007-03-30 17:11 ` paolo at gcc dot gnu dot org
2007-03-30 17:12 ` paolo at gcc dot gnu dot org
2007-03-30 17:13 ` pcarlini at suse dot de
2007-04-02 10:09 ` paolo at gcc dot gnu dot org
2007-04-02 10:09 ` paolo at gcc dot gnu dot org
2007-07-11 18:20 ` pcarlini at suse dot de

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