[Bug libstdc++/123100] std::ostringstream:str() (r-value version) returns garbage

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Fri Dec 12 09:39:38 GMT 2025


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

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
We should put the [[unlikely]] attribute on that condition, since using setbuf
is uncommon and a major benefit of the rvalue str() overload is for code like
this, which doesn't use setbuf:

    auto s = (std::ostringstream << foo << bar).str();


More information about the Gcc-bugs mailing list