C++ Standard Library
  1. C++ Standard Library
  2. STDCXX-272

[LWG #625] std::string::find_first_of() returns 0 for the empty string

    Details

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

      all

      Description

      The program below is expected to run succeffully to completion (since the returned value must be less than the size of the string) but instead it aborts.

      $ cat t.cpp && nice gmake t && ./t
      #include <cassert>
      #include <string>

      int main ()
      {
      std::string::size_type xpos =
      std::string ("").find_first_of ("cba", 0, std::string::npos);

      assert (std::string::npos == xpos);
      }

      aCC -c -I/amd/devco/sebor/dev/stdlib/include/ansi -I/usr/include -D_RWSTDDEBUG -D_RWSTD_USE_CONFIG -I/amd/devco/sebor/dev/stdlib/include -I/build/sebor/aCC-3.70-11d/include -I/amd/devco/sebor/dev/stdlib/examples/include -Aa +nostl -g +d +w +W392 +W655 +W684 +W818 +W819 +W849 t.cpp
      aCC t.o -o t -Aa +nostl -Wl,+s -Wl,+vnocompatwarnings -L/build/sebor/aCC-3.70-11d/lib -L/build/sebor/aCC-3.70-11d/lib -lstd11d -lm
      ABORT instruction (core dumped)

        Issue Links

          Activity

          No work has yet been logged on this issue.

            People

            • Assignee:
              Farid Zaripov
              Reporter:
              Martin Sebor
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development