From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26605 invoked by alias); 30 Mar 2007 14:53:04 -0000 Received: (qmail 26379 invoked by uid 48); 30 Mar 2007 14:52:46 -0000 Date: Fri, 30 Mar 2007 14:53:00 -0000 Subject: [Bug libstdc++/31401] New: string find behaves strange when searching from npos X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "Ko dot vanderSloot at uvt dot nl" Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2007-03/txt/msg02774.txt.bz2 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 #include 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