C++ Logo

std-discussion

Advanced search

Re: Setting badbit when outputting to an unopened fstream in eof state

From: Gennaro Prota <gennaro.prota_at_[hidden]>
Date: Tue, 12 Nov 2019 11:51:27 +0100
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 ::.

Received on 2019-11-12 04:54:24