istream::tellg causes character loss while using getline(string &). istream::seekg with the saved value will result in one character beyond the saved position. Release: unknown Environment: ~>gcc -v Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/2.95.2-6/specs gcc version 2.95.2-6 19991024 (cygwin experimental) How-To-Repeat: This can be demostrated with the attach code and a file with the following 2 lines (the content seem to have an impact on the result): line1 aaaaaaaa bbbbbbbb ccccccccc line2 dddddddd The running result is as follows: 0: line1 aaaaaaaa bbbbbbbb ccccccccc gcount = 0 remember 36 0: [ine2 dddddddd] restore 37 1: [ne2 dddddddd]
Fix: No idea yet.
From: benjamin kosnik <bkoz@nabi.net> To: gcc-gnats@gcc.gnu.org, nobody@gcc.gnu.org, hhuang@cs.columbia.edu Cc: Subject: Re: libstdc++/2259 Date: Mon, 12 Mar 2001 10:39:29 -0800 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=2259&database=gcc there is no attached file, so I can't reproduce your problem. Can you try this with mainline CVS or the snapshots available on-line at codesourcery.com? thanks, benjamin
From: benjamin kosnik <bkoz@nabi.net> To: Hao Huang <hhuang@cs.columbia.edu> Cc: gcc-gnats@gcc.gnu.org Subject: Re: libstdc++/2259 Date: Mon, 12 Mar 2001 18:47:11 -0800 > I just downloaded the latest cygwin gcc and the bug seems to be fixed. However, > now getline will leave the carriage return at the end of the line in the string > (which was not the case before). > > >gcc -v > Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/gcc-2.95.2-9/specs > gcc version gcc-2.95.2-9 19991024 (cygwin experimental) > > Thanks! Here's what I get with the following: #include <fstream> #include <iostream> #include <string> using namespace std; int main(int argc, char** argv) { ifstream in(argv[1]); string line; getline(in, line); cout << "0: " << line << endl; cout << "gcount = " << in.gcount() << endl; size_t pos = in.tellg(); cout << "remember " << pos << endl; while (getline(in, line)) { cout << "0: [" << line << ']' << endl; } in.clear(); in.seekg(pos, ios::beg); cout << "restore " << in.tellg() << endl; while (getline(in, line)) { cout << "1: [" << line << ']' << endl; } } %COMP.sh "-static" 2259.cpp <bkoz@fillmore> /mnt/hd/bliss/src.gcc/libstdc++-v3/testsuite %a.out 0: gcount = 0 remember 4294967295 restore -1 Again, I ask you to simplify. Please try to narrow down the problem. At least provide sample compile lines and invocation lines, and expected output? -benjamin
Responsible-Changed-From-To: unassigned->bkoz Responsible-Changed-Why: responsible.
State-Changed-From-To: open->feedback State-Changed-Why: cygwin-specific
From: bkoz@gcc.gnu.org To: bkoz@gcc.gnu.org, gcc-gnats@gcc.gnu.org, hhuang@cs.columbia.edu, nobody@gcc.gnu.org Cc: Subject: Re: libstdc++/2259 Date: 14 Mar 2001 22:52:49 -0000 Synopsis: istream::tellg/seekg cause character loss Responsible-Changed-From-To: unassigned->bkoz Responsible-Changed-By: bkoz Responsible-Changed-When: Wed Mar 14 14:52:49 2001 Responsible-Changed-Why: responsible. State-Changed-From-To: open->feedback State-Changed-By: bkoz State-Changed-When: Wed Mar 14 14:52:49 2001 State-Changed-Why: cygwin-specific http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=2259&database=gcc
State-Changed-From-To: feedback->closed State-Changed-Why: Fixed with current cygwin
From: bkoz@gcc.gnu.org To: bkoz@gcc.gnu.org, gcc-gnats@gcc.gnu.org, hhuang@cs.columbia.edu Cc: Subject: Re: libstdc++/2259 Date: 9 May 2001 06:50:42 -0000 Synopsis: istream::tellg/seekg cause character loss State-Changed-From-To: feedback->closed State-Changed-By: bkoz State-Changed-When: Tue May 8 23:50:42 2001 State-Changed-Why: Fixed with current cygwin http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=2259&database=gcc