https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81395
--- Comment #12 from Jonathan Wakely <redi at gcc dot gnu.org> --- Hmm, except that if we *do* have a pending output sequence there (i.e. data in the put area), we'd discard it, losing data. I'll try to verify that with a testcase. So we want to avoid getting into a state where we have anything in the put area while _M_reading is true, which is what comment 2 does. It looks strange, because usually _M_set_buffer(-1) is used for uncommitted mode, but what it's actually doing is nuking the buffers. The next read would need to do an underflow to refill the get area (which is correct), or the next write would need to do a seek and then an overflow to make a put area available (which is correct).