This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/80676] basic_stringbuf does not use initial capacity of SSO string


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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2017-05-08
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The fix is trivial:

--- a/libstdc++-v3/include/std/sstream
+++ b/libstdc++-v3/include/std/sstream
@@ -99,7 +99,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
       explicit
       basic_stringbuf(ios_base::openmode __mode = ios_base::in |
ios_base::out)
       : __streambuf_type(), _M_mode(__mode), _M_string()
-      { }
+      {
+#if _GLIBCXX_USE_CXX11_ABI
+       _M_stringbuf_init(__mode);
+#endif
+      }

       /**
        *  @brief  Starts with an existing string buffer.

There was no point calling _M_stringbuf_init for the COW string, because
immediately after construction there was no buffer to use. With an SSO string
that isn't true.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]