public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/26181] New: istream::operator>>(streambuf*) fails to set eofbit
@ 2006-02-08 21:51 sebor at roguewave dot com
2006-02-09 0:07 ` [Bug libstdc++/26181] " pinskia at gcc dot gnu dot org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: sebor at roguewave dot com @ 2006-02-08 21:51 UTC (permalink / raw)
To: gcc-bugs
The program below is expected to run successfully to completion.
The extractor must set eofbit even though doing so is not explicitly specified
in 27.6.1.2.3, p12, since it is specified by the blanket statement in 27.6.1.1,
p3.
$ cat t.cpp && g++ -dumpversion && g++ t.cpp -static && ./a.out
#include <cassert>
#include <fstream>
#include <sstream>
int main ()
{
std::ifstream ifs (__FILE__);
std::stringstream ss;
assert (0 == ifs.tellg ());
ifs >> ss.rdbuf ();
assert (ifs.eofbit == ifs.rdstate ());
assert (-1 == ifs.tellg ());
ifs.clear ();
assert (0 < ifs.tellg ());
ifs.get ();
assert (-1 == ifs.tellg ());
}
4.0.2
Assertion failed: ifs.eofbit == ifs.rdstate (), file t.cpp, line 14
Abort (core dumped)
This first came up here:
http://forum.sun.com/thread.jspa?threadID=28814
--
Summary: istream::operator>>(streambuf*) fails to set eofbit
Product: gcc
Version: 4.0.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: sebor at roguewave dot com
GCC build triplet: all
GCC host triplet: all
GCC target triplet: all
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26181
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/26181] istream::operator>>(streambuf*) fails to set eofbit
2006-02-08 21:51 [Bug libstdc++/26181] New: istream::operator>>(streambuf*) fails to set eofbit sebor at roguewave dot com
@ 2006-02-09 0:07 ` pinskia at gcc dot gnu dot org
2006-02-09 0:10 ` pcarlini at suse dot de
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-02-09 0:07 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2006-02-09 00:07 -------
It also fails with "4.1.0 20051026".
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26181
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/26181] istream::operator>>(streambuf*) fails to set eofbit
2006-02-08 21:51 [Bug libstdc++/26181] New: istream::operator>>(streambuf*) fails to set eofbit sebor at roguewave dot com
2006-02-09 0:07 ` [Bug libstdc++/26181] " pinskia at gcc dot gnu dot org
@ 2006-02-09 0:10 ` pcarlini at suse dot de
2006-02-09 11:53 ` pcarlini at suse dot de
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pcarlini at suse dot de @ 2006-02-09 0:10 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pcarlini at suse dot de 2006-02-09 00:10 -------
Confirmed, thanks a lot!
--
pcarlini at suse dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2006-02-09 00:10:21
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26181
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/26181] istream::operator>>(streambuf*) fails to set eofbit
2006-02-08 21:51 [Bug libstdc++/26181] New: istream::operator>>(streambuf*) fails to set eofbit sebor at roguewave dot com
2006-02-09 0:07 ` [Bug libstdc++/26181] " pinskia at gcc dot gnu dot org
2006-02-09 0:10 ` pcarlini at suse dot de
@ 2006-02-09 11:53 ` pcarlini at suse dot de
2006-02-09 17:24 ` pcarlini at suse dot de
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pcarlini at suse dot de @ 2006-02-09 11:53 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from pcarlini at suse dot de 2006-02-09 11:53 -------
Working on it.
--
pcarlini at suse dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |pcarlini at suse dot de
|dot org |
Status|NEW |ASSIGNED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26181
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/26181] istream::operator>>(streambuf*) fails to set eofbit
2006-02-08 21:51 [Bug libstdc++/26181] New: istream::operator>>(streambuf*) fails to set eofbit sebor at roguewave dot com
` (2 preceding siblings ...)
2006-02-09 11:53 ` pcarlini at suse dot de
@ 2006-02-09 17:24 ` pcarlini at suse dot de
2006-02-09 17:29 ` sebor at roguewave dot com
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pcarlini at suse dot de @ 2006-02-09 17:24 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from pcarlini at suse dot de 2006-02-09 17:24 -------
Martin, I have a patch in the making which is supposed to fix the problem.
However, with that patch applied, your testcase still fails the third
assertion, that is 'assert (-1 == ifs.tellg ());' at line 15, because tellg
returns the length of the file, not -1. By the way, Dinkum as bundled together
with ICC does the same.
I will look into that, as soon as I finish the first part of the work, but I
wonder if you could possibly also investigate a bit? Maybe we are diverging in
the implementation (not implementation) of some DRs? Thanks.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26181
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/26181] istream::operator>>(streambuf*) fails to set eofbit
2006-02-08 21:51 [Bug libstdc++/26181] New: istream::operator>>(streambuf*) fails to set eofbit sebor at roguewave dot com
` (3 preceding siblings ...)
2006-02-09 17:24 ` pcarlini at suse dot de
@ 2006-02-09 17:29 ` sebor at roguewave dot com
2006-02-09 17:35 ` pcarlini at suse dot de
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: sebor at roguewave dot com @ 2006-02-09 17:29 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from sebor at roguewave dot com 2006-02-09 17:29 -------
Here's my analysis copied from the post on the Sun C++ Forum.
According to 27.6.1.3, p36a, tellg() behaves as an unformatted input function
(as described in 27.6.1.3, p1).
>From 27.6.1.3, p1: Each unformatted input function begins execution by
constructing an object of class sentry with the default argument noskipws
(second) argument true. If the sentry object returns true, when converted to a
value of type bool, the function endeavors to obtain the requested input.
Since eofbit is set prior to calling tellg() the function must not "endeavor to
obtain the requested input." Hence it must fail.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26181
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/26181] istream::operator>>(streambuf*) fails to set eofbit
2006-02-08 21:51 [Bug libstdc++/26181] New: istream::operator>>(streambuf*) fails to set eofbit sebor at roguewave dot com
` (4 preceding siblings ...)
2006-02-09 17:29 ` sebor at roguewave dot com
@ 2006-02-09 17:35 ` pcarlini at suse dot de
2006-02-09 17:43 ` sebor at roguewave dot com
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pcarlini at suse dot de @ 2006-02-09 17:35 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from pcarlini at suse dot de 2006-02-09 17:35 -------
(In reply to comment #5)
> Here's my analysis copied from the post on the Sun C++ Forum.
[snip]
Ah, now I remember thanks! It's a very old issue, unrelated to the present one,
I remember discussing it briefly with Benjamin so *much* time ago! And I'm
pretty sure we came to the conclusion that indeed your reading of the standard
is the right one, but then didn't take any action, i.e., in practice our tellg
still doesn't have any sentry. If you agree, I'm going to deal with that
separately, however, will file a separate PR myself.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26181
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/26181] istream::operator>>(streambuf*) fails to set eofbit
2006-02-08 21:51 [Bug libstdc++/26181] New: istream::operator>>(streambuf*) fails to set eofbit sebor at roguewave dot com
` (5 preceding siblings ...)
2006-02-09 17:35 ` pcarlini at suse dot de
@ 2006-02-09 17:43 ` sebor at roguewave dot com
2006-02-10 18:29 ` paolo at gcc dot gnu dot org
2006-02-10 18:30 ` pcarlini at suse dot de
8 siblings, 0 replies; 10+ messages in thread
From: sebor at roguewave dot com @ 2006-02-09 17:43 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from sebor at roguewave dot com 2006-02-09 17:43 -------
Sure, whatever works for you :)
FWIW, I find the current behavior in this specific case quite reasonable (i.e.,
it seems reasonable to expect to be able to get the current position even when
the stream has reached the EOF) but that's not what the text says. I also have
a feeling that relaxing the text (and the implementation) to allow this
particular behavior might lead to surprises in some corner cases (I don't have
a test case or anything specific in mind, just a hunch, so it's quite possible
that I'm being overly paranoid).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26181
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/26181] istream::operator>>(streambuf*) fails to set eofbit
2006-02-08 21:51 [Bug libstdc++/26181] New: istream::operator>>(streambuf*) fails to set eofbit sebor at roguewave dot com
` (6 preceding siblings ...)
2006-02-09 17:43 ` sebor at roguewave dot com
@ 2006-02-10 18:29 ` paolo at gcc dot gnu dot org
2006-02-10 18:30 ` pcarlini at suse dot de
8 siblings, 0 replies; 10+ messages in thread
From: paolo at gcc dot gnu dot org @ 2006-02-10 18:29 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from paolo at gcc dot gnu dot org 2006-02-10 18:29 -------
Subject: Bug 26181
Author: paolo
Date: Fri Feb 10 18:29:04 2006
New Revision: 110841
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=110841
Log:
2006-10-02 Paolo Carlini <pcarlini@suse.de>
PR libstdc++/26181
* include/bits/streambuf.tcc (__copy_streambufs_eof): New, like
the existing __copy_streambufs but reporting eof in input.
(__copy_streambufs): Just use the latter.
* src/streambuf.cc (__copy_streambufs_eof): Adjust specializations
of __copy_streambufs.
* include/bits/istream.tcc (operator>>(__streambuf_type*)): Use
__copy_streambufs_eof instead.
* include/std/std_streambuf.h: Adjust.
* src/streambuf-inst.cc: Adjust.
* config/abi/pre/gnu.ver: Export the new symbols.
* testsuite/27_io/basic_istream/extractors_other/char/26181.cc: New.
* testsuite/27_io/basic_istream/extractors_other/wchar_t/26181.cc:
Likewise.
* testsuite/27_io/basic_istream/extractors_other/char/1.cc: Adjust.
* testsuite/27_io/basic_istream/extractors_other/wchar_t/1.cc:
Likewise.
Added:
trunk/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/26181.cc
trunk/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/26181.cc
Modified:
trunk/libstdc++-v3/ChangeLog
trunk/libstdc++-v3/config/abi/pre/gnu.ver
trunk/libstdc++-v3/include/bits/istream.tcc
trunk/libstdc++-v3/include/bits/streambuf.tcc
trunk/libstdc++-v3/include/std/std_streambuf.h
trunk/libstdc++-v3/src/streambuf-inst.cc
trunk/libstdc++-v3/src/streambuf.cc
trunk/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/1.cc
trunk/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/1.cc
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26181
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug libstdc++/26181] istream::operator>>(streambuf*) fails to set eofbit
2006-02-08 21:51 [Bug libstdc++/26181] New: istream::operator>>(streambuf*) fails to set eofbit sebor at roguewave dot com
` (7 preceding siblings ...)
2006-02-10 18:29 ` paolo at gcc dot gnu dot org
@ 2006-02-10 18:30 ` pcarlini at suse dot de
8 siblings, 0 replies; 10+ messages in thread
From: pcarlini at suse dot de @ 2006-02-10 18:30 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from pcarlini at suse dot de 2006-02-10 18:30 -------
Fixed for 4.2.0.
--
pcarlini at suse dot de changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
Target Milestone|--- |4.2.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26181
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2006-02-10 18:30 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-08 21:51 [Bug libstdc++/26181] New: istream::operator>>(streambuf*) fails to set eofbit sebor at roguewave dot com
2006-02-09 0:07 ` [Bug libstdc++/26181] " pinskia at gcc dot gnu dot org
2006-02-09 0:10 ` pcarlini at suse dot de
2006-02-09 11:53 ` pcarlini at suse dot de
2006-02-09 17:24 ` pcarlini at suse dot de
2006-02-09 17:29 ` sebor at roguewave dot com
2006-02-09 17:35 ` pcarlini at suse dot de
2006-02-09 17:43 ` sebor at roguewave dot com
2006-02-10 18:29 ` paolo at gcc dot gnu dot org
2006-02-10 18:30 ` pcarlini at suse dot de
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).