https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94007

            Bug ID: 94007
           Summary: Appending a view into a string to the same string
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: philwill at fb dot com
  Target Milestone: ---

std::string a = "...whatever...";
  a.append(a.data(), a.size());
  // a must now contain 2 copies of whatever it had in it before

With current trunk libstdc++ this doesn't work if `a` needs to be resized
during `append` because the original buffer is deallocated before the copy of
the bytes being appended is performed.

Anyone encountering this bug can work around it by ensuring that they have
called `reserve` with an appropriate size before calling `append` so that
`append` does not need to resize the buffer.

Reply via email to