public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: Carlo Wood <carlo@alinoe.com> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org Subject: Re: libstdc++/4686: Output disappearing after operator<<( streambuf* ) Date: Thu, 25 Oct 2001 21:06:00 -0000 [thread overview] Message-ID: <20011026040602.4363.qmail@sourceware.cygnus.com> (raw) The following reply was made to PR libstdc++/4686; it has been noted by GNATS. From: Carlo Wood <carlo@alinoe.com> To: kanze@gabi-soft.de Cc: gcc-gnats@gcc.gnu.org Subject: Re: libstdc++/4686: Output disappearing after operator<<( streambuf* ) Date: Fri, 26 Oct 2001 06:00:57 +0200 On Thu, Oct 25, 2001 at 05:49:35PM -0000, kanze@gabi-soft.de wrote: > #include <sstream> > #include <ostream> > #include <iostream> > > int > main() > { > std::istringstream i1( "3\n" ) ; > std::cout << i1.rdbuf() ; > std::cout << "4\n" ; > return 0 ; > } The reason that nothing is written the second time is beause badbit is set for std::cout. It seems to be set here: 0x0804e134 in std::ostream::sentry::~sentry() (__in_chrg=0xbffff510) at /usr/local/gcc-cvs-3.0/include/g++-v3/bits/std_ostream.h:200 200 _M_os.setstate(ios_base::badbit); (gdb) l 195 // XXX MT 196 if (_M_os.flags() & ios_base::unitbuf && !uncaught_exception()) 197 { 198 // Can't call flush directly or else will get into recursive lock. 199 if (_M_os.rdbuf() && _M_os.rdbuf()->pubsync() == -1) 200 _M_os.setstate(ios_base::badbit); 201 } 202 } right after the call to std::cout << i1.rdbuf(); This indeed seems to be a bug, because - this code seems to try to flush and sets badbit when that fails. However, there is nothing to flush because std::cout is both 1) unbuffered, 2) empty. That is hardly a case where an *attempt* to flush it can cause an error. -- Carlo Wood <carlo@alinoe.com>
next reply other threads:[~2001-10-25 21:06 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2001-10-25 21:06 Carlo Wood [this message] -- strict thread matches above, loose matches on Subject: below -- 2002-01-13 15:24 rodrigc 2001-10-25 23:35 bkoz 2001-10-25 16:28 kanze
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=20011026040602.4363.qmail@sourceware.cygnus.com \ --to=carlo@alinoe.com \ --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).