This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/80676] basic_stringbuf does not use initial capacity of SSO string
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 08 May 2017 19:33:08 +0000
- Subject: [Bug libstdc++/80676] basic_stringbuf does not use initial capacity of SSO string
- Auto-submitted: auto-generated
- References: <bug-80676-4@http.gcc.gnu.org/bugzilla/>
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.