C++ Logo

STD-DISCUSSION

Advanced search

Subject: Re: Setting badbit when outputting to an unopened fstream in eof state
From: Gennaro Prota (gennaro.prota_at_[hidden])
Date: 2019-11-12 04:51:27


On Thu, Nov 7, 2019 at 3:23 PM Gennaro Prota <gennaro.prota_at_[hidden]> wrote:
    [...]
> > But, anyway, the libary code does one thing for string output (after
> > creating the sentry object):
> >
> > if (!_Ok) {
> > _State |= _Ostr_t::badbit;
> > } else { // state okay, insert characters
> >
> > }
> >
> > and another thing for all other types
> >
> > if (_Ok) { // state okay, insert
> >
> > }
> >
> >
> > So, why do they do that? Historical reasons? I don't know.
>
> Ah, thanks for finding that. I hadn't looked at Microsoft sources.

I reported this to Stephan T. Lavavej, who opened:

  <https://github.com/microsoft/STL/issues/283>.

Note that he found a difference between formatted and unformatted output
functions in this regard. I'm not sure why such a difference exists.
(And I'm not sure which draft he looked at.)

-- 
--
.:: Gennaro Prota ::.
.:: https://about.me/gennaro.prota ::.

STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups