This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/80676] New: 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 18:02:31 +0000
- Subject: [Bug libstdc++/80676] New: basic_stringbuf does not use initial capacity of SSO string
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80676
Bug ID: 80676
Summary: basic_stringbuf does not use initial capacity of SSO
string
Product: gcc
Version: 8.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
The following prints "overflow":
#include <sstream>
#include <iostream>
struct SB : std::stringbuf
{
int_type overflow(int_type c) override
{
std::cout << "overflow\n";
return std::stringbuf::overflow(c);
}
};
int main()
{
SB sb;
std::ostringstream s;
s.std::ios::rdbuf(&sb);
s.put('a');
}
The call to the virtual function should not be necessary when using the new
ABI, because the SSO string has an initial non-zero capacity. The stringbuf
could use it.