This is for all flavors of find.

According to the documentation I can find.

#include <iostream>
#include <string>

using namespace std;

int main(int argc, char **argv)
{
    string test("this should be a bunch of words");
    size_t p = test.find("s");  // correct at 3
    cerr << "p = " << p << ", npos = " << string::npos << endl;
    p = test.find("s", 5);      // correct at 5
    cerr << "p = " << p << ", npos = " << string::npos << endl;
    p = test.find("s", 5, 5);   // incorrect, should be 5 is npos
    cerr << "p = " << p << ", npos = " << string::npos << endl;
}

-- 
           Summary: Using std::string find the n field always causes nothing
                    to be found
           Product: gcc
           Version: 3.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: grogers at cray dot com
                CC: gcc-bugs at gcc dot gnu dot org


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

Reply via email to