https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81381
Bug ID: 81381 Summary: std::basic_stringbuf only works with DefaultConstructible allocators Product: gcc Version: 8.0 Status: UNCONFIRMED Keywords: rejects-valid Severity: normal Priority: P3 Component: libstdc++ Assignee: unassigned at gcc dot gnu.org Reporter: redi at gcc dot gnu.org Target Milestone: --- #include <memory> #include <sstream> #include <cassert> template<typename T> struct Alloc : std::allocator<T> { template<typename U> struct rebind { using other = Alloc<U>; }; Alloc(int id) : id(id) { } template<typename U> Alloc(const Alloc<U>& a) : id(a.id) { } int id; }; using string = std::basic_string<char, std::char_traits<char>, Alloc<char>>; struct SB : std::basic_stringbuf<char, std::char_traits<char>, Alloc<char>> { SB(const string& s) : basic_stringbuf(s) { } using basic_stringbuf::overflow; }; int main() { string s(Alloc<char>(1)); SB b(s); b.overflow('a'); assert( b.str().get_allocator() == s.get_allocator() ); }