public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: lennox@cs.columbia.edu To: gcc-gnats@gcc.gnu.org Subject: libstdc++/8071: basic_ostream::operator<<(streambuf*) loops forever if streambuf::underflow() leaves gptr() NULL Date: Fri, 27 Sep 2002 08:56:00 -0000 [thread overview] Message-ID: <20020927154817.11030.qmail@sources.redhat.com> (raw) >Number: 8071 >Category: libstdc++ >Synopsis: basic_ostream::operator<<(streambuf*) loops forever if streambuf::underflow() leaves gptr() NULL >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Fri Sep 27 08:56:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: lennox@cs.columbia.edu >Release: gcc-3.1 >Organization: >Environment: sparc-sun-solaris2.8 >Description: According to my reading of the C++ standard, a subclass of std::basic_streambuf<> is allowed to declare its uflow() and underflow() functions such that they don't fill their buffers. This is useful, for instance, if the streambuf is a wrapper around another type that does its own buffering. However, libstdc++'s basic_ostream::operator<<(streambuf*) operator loops forever when passed such a streambuf, repeatedly invoking underflow() and never actually extracting any data from the buffer. I've attached some code written by Matt Austern, and published in the C++ Users Journal. This code creates a streambuf and istream that wraps a C FILE*, so I/O can safely be intermixed on the two types. Using operator<< on the syncbuf this code declares illustrates the problem. >How-To-Repeat: Compile the attached code. (It looks like gnats won't allow me to attach more than one file in the initial bug report, so I've just attached the header. I'll attach the body momentarily.) >Fix: I think the fix needs to change basic_streambuf::__copy_streambufs, but I'm not sure exactly what the fix should be. >Release-Note: >Audit-Trail: >Unformatted: ----gnatsweb-attachment---- Content-Type: application/octet-stream; name="syncstream.h" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="syncstream.h" Ly8gLSotIEMrKyAtKi0KCi8qIENvZGUgYnkgTWF0dCBBdXN0ZXJuLCBmcm9tIHRoZSBDL0MrKyBV c2VycyBKb3VybmFsOgogKiA8aHR0cDovL3d3dy5jdWouY29tL2V4cGVydHMvMTgxMS9hdXN0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OnVmbG93KCkgewogICByZXR1cm4gZ2V0YyhmcHRyKTsKfQoKaW50IHN5bmNidWY6OnBi YWNrZmFpbChpbnQgYykgewogICByZXR1cm4gYyAhPSBFT0YgPyB1bmdldGMoYywgZnB0cikgOiBF T0Y7Cn0KCmludCBzeW5jYnVmOjpzeW5jKCkgewogICByZXR1cm4gZmZsdXNoKGZwdHIpOwp9CgoK CmNsYXNzIGlzeW5jc3RyZWFtCiAgIDogcHVibGljIHN0ZDo6aXN0cmVhbSB7CnB1YmxpYzoKICAg aXN5bmNzdHJlYW0oKQogICAgICA6IHN0ZDo6aXN0cmVhbSgmYnVmKSwgYnVmKDApIHt9CiAgIGlz eW5jc3RyZWFtKEZJTEUqIGZwdHIpCiAgICAgIDogc3RkOjppc3RyZWFtKCZidWYpLCBidWYoZnB0 cikge30KICAgc3luY2J1ZiogcmRidWYoKSBjb25zdCB7CiAgICAgIHJldHVybiBjb25zdF9jYXN0 PHN5bmNidWYqPigmYnVmKTsKICAgfQpwcml2YXRlOgogICBzeW5jYnVmIGJ1ZjsKfTsKCiNlbmRp Zgo=
next reply other threads:[~2002-09-27 15:56 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-09-27 8:56 lennox [this message] 2002-09-27 9:16 Jonathan Lennox 2002-10-20 9:32 bkoz 2002-11-06 8:47 bkoz
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=20020927154817.11030.qmail@sources.redhat.com \ --to=lennox@cs.columbia.edu \ --cc=gcc-gnats@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).