public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: libstdc++/8071: basic_ostream::operator<<(streambuf*) loops forever if streambuf::underflow() leaves gptr() NULL
@ 2002-11-06  8:47 bkoz
  0 siblings, 0 replies; 4+ messages in thread
From: bkoz @ 2002-11-06  8:47 UTC (permalink / raw)
  To: bkoz, gcc-bugs, gcc-prs, lennox

Synopsis: basic_ostream::operator<<(streambuf*) loops forever if streambuf::underflow() leaves gptr() NULL

State-Changed-From-To: feedback->closed
State-Changed-By: bkoz
State-Changed-When: Wed Nov  6 08:47:06 2002
State-Changed-Why:
    Fixed.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8071


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: libstdc++/8071: basic_ostream::operator<<(streambuf*) loops forever if streambuf::underflow() leaves gptr() NULL
@ 2002-10-20  9:32 bkoz
  0 siblings, 0 replies; 4+ messages in thread
From: bkoz @ 2002-10-20  9:32 UTC (permalink / raw)
  To: bkoz, gcc-bugs, gcc-prs, lennox, nobody

Synopsis: basic_ostream::operator<<(streambuf*) loops forever if streambuf::underflow() leaves gptr() NULL

Responsible-Changed-From-To: unassigned->bkoz
Responsible-Changed-By: bkoz
Responsible-Changed-When: Sun Oct 20 09:32:46 2002
Responsible-Changed-Why:
    Mine.
State-Changed-From-To: open->feedback
State-Changed-By: bkoz
State-Changed-When: Sun Oct 20 09:32:46 2002
State-Changed-Why:
    I think this is fixed.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8071


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: libstdc++/8071: basic_ostream::operator<<(streambuf*) loops forever if streambuf::underflow() leaves gptr() NULL
@ 2002-09-27  9:16 Jonathan Lennox
  0 siblings, 0 replies; 4+ messages in thread
From: Jonathan Lennox @ 2002-09-27  9:16 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR libstdc++/8071; it has been noted by GNATS.

From: Jonathan Lennox <lennox@cs.columbia.edu>
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: Re: libstdc++/8071: basic_ostream::operator<<(streambuf*) loops forever if streambuf::underflow() leaves gptr() NULL
Date: Fri, 27 Sep 2002 12:10:26 -0400

 --prVVYBvZNE
 Content-Type: text/plain; charset=us-ascii
 Content-Description: message body text
 Content-Transfer-Encoding: 7bit
 
 Here is the additional code, which uses the header file previously
 attached.
 
 
 --prVVYBvZNE
 Content-Type: text/plain
 Content-Disposition: inline;
 	filename="test-syncstream.cxx"
 Content-Transfer-Encoding: 7bit
 
 #include "syncstream.h"
 
 using namespace std;
 
 int main(int argc, char *argv[]) 
 {
   if (argc < 2) {
     cerr << "Usage: " << argv[0] << " [file]" << endl;
     exit(2);
   }
   FILE* c_file = fopen(argv[1], "r");
 
   if (c_file == NULL) {
     perror(argv[1]);
     exit(1);
   }
 
   isyncstream cxx_file(c_file);
 
   cout << cxx_file.rdbuf();
 
   exit(0);
 }
 
 --prVVYBvZNE--


^ permalink raw reply	[flat|nested] 4+ messages in thread

* libstdc++/8071: basic_ostream::operator<<(streambuf*) loops forever if streambuf::underflow() leaves gptr() NULL
@ 2002-09-27  8:56 lennox
  0 siblings, 0 replies; 4+ messages in thread
From: lennox @ 2002-09-27  8:56 UTC (permalink / raw)
  To: gcc-gnats


>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
c2VycyBKb3VybmFsOgogKiA8aHR0cDovL3d3dy5jdWouY29tL2V4cGVydHMvMTgxMS9hdXN0ZXJu
Lmh0bT90b3BpYz1leHBlcnRzPgogKiBNaW5vciB0d2Vha3MgKHN0ZDo6IGFuZCBjb25zdF9jYXN0
PD4gY29ycmVjdG5lc3MpIGJ5CiAqIEpvbmF0aGFuIExlbm5veCA8bGVubm94QGNzLmNvbHVtYmlh
LmVkdT4KICovCgovKiBzeW5jYnVmIGFuZCBpc3luY3N0cmVhbTogc3luY2hyb25pemUgSS9PIG9u
IGEgQyBGSUxFKiBhbmQgYQogKiBDKysgaW9zdHJlYW0uICovCgojaW5jbHVkZSA8aW9zdHJlYW0+
CiNpbmNsdWRlIDxzdGRpby5oPgoKI2lmbmRlZiBTWU5DQlVGX0hfCiNkZWZpbmUgU1lOQ0JVRl9I
XwoKY2xhc3Mgc3luY2J1ZiA6IHB1YmxpYyBzdGQ6OnN0cmVhbWJ1ZiB7CnB1YmxpYzoKICAgc3lu
Y2J1ZihGSUxFKik7Cgpwc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AgICAgIHJldHVybiBjb25zdF9jYXN0
PHN5bmNidWYqPigmYnVmKTsKICAgfQpwcml2YXRlOgogICBzeW5jYnVmIGJ1ZjsKfTsKCiNlbmRp
Zgo=


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-11-06 16:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-06  8:47 libstdc++/8071: basic_ostream::operator<<(streambuf*) loops forever if streambuf::underflow() leaves gptr() NULL bkoz
  -- strict thread matches above, loose matches on Subject: below --
2002-10-20  9:32 bkoz
2002-09-27  9:16 Jonathan Lennox
2002-09-27  8:56 lennox

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).