This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: tellg modifying the state of an input file stream
- From: Ivan Kolev <ikolev at abac dot com>
- To: libstdc++ at gcc dot gnu dot org
- Date: Sun, 21 May 2006 00:22:33 +0300
- Subject: Re: tellg modifying the state of an input file stream
- References: <1148134788.31547.ezmlm@gcc.gnu.org> <446F28AD.2030201@abac.com> <446F71DF.8090202@suse.de>
Paolo Carlini wrote:
The correct output, which I actually get on x86-linux (and all the other
arches I have available), would be:
c = T, pos: 1
c = e, pos: 2
c = s, pos: 3
c = t, pos: 4
c =
, pos: 5
if you are really seeing something different, then it's something MinGW
specific and I would suggest reporting it to the maintainers of that
project, to begin with, because if you are *really* seeing the first
output above, then something is *badly* broken for that target and can't
be a bug in the generic code (nobody would use our library for serious
projects ;)
Hi Paolo,
There is one possibility for the problem to be in generic code and that it hasn't been spotted until now - it seems the problem is related to the \r\n line endings on Windows (you mention x86 *linux*, and it seems most GCC users are on Unix systems). A few more tests showed the following dependency: the skipping of the offset after each read is related to the number of newlines remaining till the end of the file. E.g., if I change line <1> in the program to the following
ofs << "Test" << endl << "Test" << endl;
the result is
c = T, pos: 3
c = t, pos: 6
c = T, pos: 8
c = s, pos: 10
c =
, pos: 12
Unfortunately I cannot debug the example myself because I'm not very experienced with GCC and GDB and I cannot make the CodeBlocks IDE step into libstdc++'s code.
Thanks,
Ivan