Uploaded image for project: 'C++ Standard Library'
  1. C++ Standard Library
  2. STDCXX-1035

Issue with string::find(const string& str, size_type pos=0)

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 4.1.4, 4.2.0, 4.2.1
    • Fix Version/s: 4.2.2
    • Component/s: 21. Strings
    • Labels:
      None
    • Environment:

      All

    • Regression:
      Regression
    • Severity:
      Incorrect Behavior

      Description

      I recently encountered a problem with stdcxx demonstrated by the following example:

      #include <string>
      
      int main()
      {
          std::string s = ".google.com";
          std::string s1 = "www.google.google.com";
      
          std::string::size_type pos = s1.find(s);
          if (pos != std::string::npos)
          {
              return 0;
          }
          else
          {
              return 1;
          }
      }
      

      The code above was compiled using the sun studio 12 compiler:

      CC -library=%none -I/spare/include/stdcxx -L/spare/lib -lstd12d -mt -lpthread google.cpp
      

      With the stdcxx 4.2.1 library, the return code is 1 indicating that find failed. However the return code is 0 when using sun studio with the Cstd or STLPort4 libraries. Compiling with g++ 4.1 on Linux also returns 0 indicating that find was successful.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                farid Farid Zaripov
                Reporter:
                briannesbitt Brian Nesbitt
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: