diff --git a/libstdc++-v3/include/std/sstream b/libstdc++-v3/include/std/sstream index 9cca54d17d1582d587b1be4968b95961fd95e1b0..06960e30bf22c7ac6d2bf7fa8cccd77fab9fa731 100644 --- a/libstdc++-v3/include/std/sstream +++ b/libstdc++-v3/include/std/sstream @@ -178,13 +178,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11 str() const { __string_type __ret(_M_string.get_allocator()); - if (this->pptr()) + if (char_type* __pptr = this->pptr()) { + char_type* __egptr = this->egptr(); // The current egptr() may not be the actual string end. - if (this->pptr() > this->egptr()) - __ret.assign(this->pbase(), this->pptr()); + if (!__egptr || __pptr > __egptr) + __ret.assign(this->pbase(), __pptr); else - __ret.assign(this->pbase(), this->egptr()); + __ret.assign(this->pbase(), __egptr); } else __ret = _M_string;