public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: bkoz@gcc.gnu.org To: bkoz@gcc.gnu.org, brendan@zen.org, gcc-bugs@gcc.gnu.org, gcc-prs@gcc.gnu.org, nobody@gcc.gnu.org Subject: Re: libstdc++/4545: basic_ostream op<< should set badbit, not failbit Date: Thu, 25 Oct 2001 21:36:00 -0000 [thread overview] Message-ID: <20011026043644.11387.qmail@sourceware.cygnus.com> (raw) Synopsis: basic_ostream op<< should set badbit, not failbit Responsible-Changed-From-To: unassigned->bkoz Responsible-Changed-By: bkoz Responsible-Changed-When: Thu Oct 25 21:36:43 2001 Responsible-Changed-Why: Mine. State-Changed-From-To: open->feedback State-Changed-By: bkoz State-Changed-When: Thu Oct 25 21:36:43 2001 State-Changed-Why: Brendan, thanks for pointing this out. I think that badbit is set when the streambuf is null, and failbit is set when no characters were copied. I believe this is consistent with a careful read of the standard: 1: If sb is null calls setstate(badbit) 2: If the function inserts no characters, it calls setstate(failbit) Anyway. I believe the function should look like this: template<typename _CharT, typename _Traits> basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::operator<<(__streambuf_type* __sbin) { sentry __cerb(*this); if (__cerb) { try { streamsize __xtrct = 0; if (__sbin) { __streambuf_type* __sbout = this->rdbuf(); __xtrct = __copy_streambufs(*this, __sbin, __sbout); } else this->setstate(ios_base::badbit); if (!__xtrct) this->setstate(ios_base::failbit); } catch(exception& __fail) { // 27.6.2.5.1 Common requirements. // Turn this on without causing an ios::failure to be thrown. this->setstate(ios_base::badbit); if ((this->exceptions() & ios_base::badbit) != 0) __throw_exception_again; } } return *this; } http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&pr=4545&database=gcc
next reply other threads:[~2001-10-25 21:36 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2001-10-25 21:36 bkoz [this message] -- strict thread matches above, loose matches on Subject: below -- 2001-11-04 4:16 bkoz 2001-11-04 3:49 bkoz 2001-10-14 12:36 libstdc++/4545 " Craig Rodrigues 2001-10-11 8:26 libstdc++/4545: " brendan
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20011026043644.11387.qmail@sourceware.cygnus.com \ --to=bkoz@gcc.gnu.org \ --cc=brendan@zen.org \ --cc=gcc-bugs@gcc.gnu.org \ --cc=gcc-prs@gcc.gnu.org \ --cc=nobody@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).