public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: libstdc++/8258: basic_istream::readsome() with default buffer change stream state to ios_base::eofbit
@ 2002-11-05 15:17 bkoz
0 siblings, 0 replies; 3+ messages in thread
From: bkoz @ 2002-11-05 15:17 UTC (permalink / raw)
To: bkoz, gcc-bugs, gcc-prs, johnb, nobody
Synopsis: basic_istream::readsome() with default buffer change stream state to ios_base::eofbit
Responsible-Changed-From-To: unassigned->bkoz
Responsible-Changed-By: bkoz
Responsible-Changed-When: Tue Nov 5 15:17:23 2002
Responsible-Changed-Why:
Mine.
State-Changed-From-To: open->feedback
State-Changed-By: bkoz
State-Changed-When: Tue Nov 5 15:17:23 2002
State-Changed-Why:
Fixed.
It's not possible to convert streamsize to int_type for this generic template. Thus, the change to just compare streamsize against zero. A modified version of this will fix this test case.
thanks
benjamin
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8258
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: libstdc++/8258: basic_istream::readsome() with default buffer change stream state to ios_base::eofbit
@ 2002-11-06 8:53 bkoz
0 siblings, 0 replies; 3+ messages in thread
From: bkoz @ 2002-11-06 8:53 UTC (permalink / raw)
To: bkoz, gcc-bugs, gcc-prs, johnb
Synopsis: basic_istream::readsome() with default buffer change stream state to ios_base::eofbit
State-Changed-From-To: feedback->closed
State-Changed-By: bkoz
State-Changed-When: Wed Nov 6 08:53:53 2002
State-Changed-Why:
Fixed.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8258
^ permalink raw reply [flat|nested] 3+ messages in thread
* libstdc++/8258: basic_istream::readsome() with default buffer change stream state to ios_base::eofbit
@ 2002-10-17 9:56 johnb
0 siblings, 0 replies; 3+ messages in thread
From: johnb @ 2002-10-17 9:56 UTC (permalink / raw)
To: gcc-gnats
>Number: 8258
>Category: libstdc++
>Synopsis: basic_istream::readsome() with default buffer change stream state to ios_base::eofbit
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Oct 17 09:56:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Eugeny Belov
>Release: g++ v3.2
>Organization:
>Environment:
Red Hat linux 8.0 release
>Description:
Possibly this is not a bug, but the g++ v3.1 version of basic_istream::readsome() don`t change the stream state in case of using default basic_streambuf constructor (zero length buffer). Here is an example:
#include <istream>
#include <cassert>
using namespace std;
class mybuf : public basic_streambuf <char> {
};
int main ()
{
char arr[10];
mybuf sbuf;
basic_istream <char, char_traits<char> > istr(&sbuf);
assert (istr.rdstate() == ios_base::goodbit);
assert (istr.readsome(arr, 10) == 0);
assert (istr.rdstate() == ios_base::goodbit);
return 0;
}
The result here is that the last assertion is failing with g++ v3.2.
I found in ISO/IEC 14882 C++ standard (27.6.1.3.30) only 2 possibilities of changing the stream state related to readsome():
1. if !good() - setstate (failbit)
2. if rdbuf()->in_avail() == -1 - setstate (eofbit)
The example above gives:
1. good() == true
2. rdbuf()->in_avail() == 0 (!= -1)
so, I can expect that stream state will not change.
I made a diff for 3.1 and 3.2 versions of bits/istream.tcc and noted that here are the following changes which give such unexpected (for me) behavior:
streamsize __num = this->rdbuf()->in_avail();
3.1:
if (__num != static_cast <streamsize>(__eof))
{ ...read from buffer... }
else this->setstate (ios_base::eofbit)
3.2:
if (__num > 0)
{ ...read from buffer... }
else this->setstate (ios_base::eofbit)
Shure, changing the stream state in such case can be useful, but my opinion is that previous version was more standard conformant.
>How-To-Repeat:
Compile attached testcaes with g++ v3.2 and run.
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/octet-stream; name="istr_readsome.cpp"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="istr_readsome.cpp"
I2luY2x1ZGUgPGlzdHJlYW0+CiNpbmNsdWRlIDxjYXNzZXJ0PgoKdXNpbmcgbmFtZXNwYWNlIHN0
ZDsKCgpjbGFzcyBteWJ1ZiA6IHB1YmxpYyBiYXNpY19zdHJlYW1idWYgPGNoYXI+IHsKCX07Cgpp
bnQgbWFpbiAoKSAKIHsKICAgIGNoYXIgYXJyWzEwXTsKICAgIG15YnVmIHNidWY7CiAgICBiYXNp
Y19pc3RyZWFtIDxjaGFyLCBjaGFyX3RyYWl0czxjaGFyPiA+IGlzdHIoJnNidWYpOwoKICAgIGFz
c2VydCAoaXN0ci5yZHN0YXRlKCkgPT0gaW9zX2Jhc2U6Omdvb2RiaXQpOwogICAgYXNzZXJ0IChp
c3RyLnJlYWRzb21lKGFyciwgMTApID09IDApOwogICAgYXNzZXJ0IChpc3RyLnJkc3RhdGUoKSA9
PSBpb3NfYmFzZTo6Z29vZGJpdCk7CgogIHJldHVybiAwOwogfQoK
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-11-06 16:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-05 15:17 libstdc++/8258: basic_istream::readsome() with default buffer change stream state to ios_base::eofbit bkoz
-- strict thread matches above, loose matches on Subject: below --
2002-11-06 8:53 bkoz
2002-10-17 9:56 johnb
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).