public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: libstdc++/6238: ifstream::getline(...) has problems reading file after long line.
@ 2002-04-09 11:50 bkoz
  0 siblings, 0 replies; 3+ messages in thread
From: bkoz @ 2002-04-09 11:50 UTC (permalink / raw)
  To: bkoz, gcc-bugs, gcc-prs, nobody, tabrunn

Synopsis: ifstream::getline(...) has problems reading file after long line.

Responsible-Changed-From-To: unassigned->bkoz
Responsible-Changed-By: bkoz
Responsible-Changed-When: Tue Apr  9 11:50:40 2002
Responsible-Changed-Why:
    Mine.
State-Changed-From-To: open->analyzed
State-Changed-By: bkoz
State-Changed-When: Tue Apr  9 11:50:40 2002
State-Changed-Why:
    Thanks for the clear description, well-designed test case. I've reproduced this on linux. More shortly.....
    
    -benjamin

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


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

* Re: libstdc++/6238: ifstream::getline(...) has problems reading file after long line.
@ 2002-04-09 12:16 bkoz
  0 siblings, 0 replies; 3+ messages in thread
From: bkoz @ 2002-04-09 12:16 UTC (permalink / raw)
  To: bkoz, gcc-bugs, gcc-prs, tabrunn

Synopsis: ifstream::getline(...) has problems reading file after long line.

State-Changed-From-To: analyzed->closed
State-Changed-By: bkoz
State-Changed-When: Tue Apr  9 12:16:21 2002
State-Changed-Why:
    This isn't a bug. The specification for getline says that failbit will be set if n items are read without hitting the delimiter. That's what is happening here.
    
    If you change
    
      while(!infile.eof() && record_count < 200)
    
    to
    
      while(infile.good())
    
    You'll get the results you expect. 
    
    -benjamin

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


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

* libstdc++/6238: ifstream::getline(...) has problems reading file after long line.
@ 2002-04-09  8:16 tabrunn
  0 siblings, 0 replies; 3+ messages in thread
From: tabrunn @ 2002-04-09  8:16 UTC (permalink / raw)
  To: gcc-gnats


>Number:         6238
>Category:       libstdc++
>Synopsis:       ifstream::getline(...) has problems reading file after long line.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Apr 09 08:16:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Tom Brunner
>Release:        all stdlib++'s that I've tested
>Organization:
>Environment:
Redhat 7.2, gcc 2.96 20000731 (Red Hat Linux 7.1 2.96-98), gcc 3.0.2 20010905 (Red Hat Linux 7.1 3.0.1-3), gcc version 3.1 20020325 (prerelease)
>Description:
When attempting to read a long line with
ifstream::getline(), the fist part of the line, up to the 
limit specified in the call, is correct.  Subsequent calls
to getline return nothing.  The attached source code exposes
this bug on all gcc versions that I have tried it on on
my Linux box.  On other compilers (on Irix, OSF1, HP-UX,
and AIX), this program runs as expected.
(Returns chunks of the line until the file is finished.)
>How-To-Repeat:
Compile the attached code with g++ (one of the versions
listed above).  Run the executable.  The input file name
can be changed to any file with long lines.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/x-c++src; name="ifstreamtest.C"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="ifstreamtest.C"

CiNpbmNsdWRlIDxmc3RyZWFtPgojaW5jbHVkZSA8aW9zdHJlYW0+CiNpbmNsdWRlIDxpb21hbmlw
Pgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKLy8gVGhpcyBsaW5lIHNob3VsZCBjYXVzZSBhbiBpbmZp
bml0ZSBsb29wIHdoZW4gdGhpcyBjb21waWxlZCBwcm9ncmFtIGlzIHVzZWQgdG8gcmVhZCB0aGlz
IHNvdXJjZSBmaWxlLi4gIEFueSBsb25nLWxpbmVkIGZpbGUgd2lsbCBkbywgbm90IGp1c3QgdGhp
cyBvbmUuCgoKaW50IG1haW4oKXsKCiAgIGlmc3RyZWFtIGluZmlsZTsKICAgY29uc3QgY2hhciAq
IGluZmlsZV9uYW1lID0gImlmc3RyZWFtdGVzdC5DIjsKICAgY29uc3QgdW5zaWduZWQgaW50IG1h
eF9saW5lX2xlbmd0aCA9IDEwMDsKCiAgIGluZmlsZS5vcGVuKGluZmlsZV9uYW1lLCBpb3M6Omlu
KTsKICAgY2hhciBpbmJ1ZlttYXhfbGluZV9sZW5ndGgrMV07CiAgIGludCByZWNvcmRfY291bnQg
PSAwOwoKICAgLy8gUmVhZCB0aGUgaW5wdXQgZmlsZSB1bnRpbCBhbiBlb2YgaXMgZW5jb3VudGVy
ZWQuCiAgIC8vIFRoZSByZWNvcmQgY291bnQgaXMgaGVyZSB0byB0ZXJtaW5hdGUgdGhlIGluZmlu
aXRlIGxvb3AuCiAgIHdoaWxlKCFpbmZpbGUuZW9mKCkgJiYgcmVjb3JkX2NvdW50IDwgMjAwKQog
ICB7CiAgICAgIC8vIEFmdGVyIHRoZSBmaXJzdCBwYXJ0IG9mIHRoZSBsb25nIGxpbmUgaXMgcmVh
ZCwgaXQgc2VlbXMgCiAgICAgIC8vIHRoYXQgdGhlIHJlc3Qgb2YgdGhlIGxpbmUgc2hvdWxkIGJl
IHJlYWQgdGhlIG5leHQgdGltZSAKICAgICAgLy8gdGhyb3VnaC4gIEluc3RlYWQsIGluZmlsZS5n
ZXRsaW5lKCkgd2lsbCBhbHdheXMgcmV0dXJuIAogICAgICAvLyBhIG5ld2xpbmUgY2hhcmFjdGVy
LiAgVGhpcyBjYXVzZXMgYW4gaW5maW5pdGUgbG9vcC4KICAgICAgaW5maWxlLmdldGxpbmUoaW5i
dWYsbWF4X2xpbmVfbGVuZ3RoKTsKICAgICAgY291dCA8PCBpbmJ1ZiA8PCBlbmRsOwogICAgICBy
ZWNvcmRfY291bnQrKzsKICAgfQoKICAgcmV0dXJuIDA7Cgp9Cg==


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

end of thread, other threads:[~2002-04-09 19:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-09 11:50 libstdc++/6238: ifstream::getline(...) has problems reading file after long line bkoz
  -- strict thread matches above, loose matches on Subject: below --
2002-04-09 12:16 bkoz
2002-04-09  8:16 tabrunn

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