This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: Behavior of ifstream::read() in g++
- From: Danny Smith <dannysmith at clear dot net dot nz>
- To: Cygwin <cygwin at cygwin dot com>
- Date: Mon, 16 Oct 2006 09:01:11 +1300
- Subject: Re: Behavior of ifstream::read() in g++
Alex Vinokur
Sunday, 15 October 2006 5:10 p.m.
> This program has different behavior in
> * g++ 3.4.4 (Cygwin)
> * gpp 4.0.1 *Djgpp)
> * Microsoft C++ 13.00.9466
>
> ------- foo.cpp ------
> #include <iostream>
> #include <iomanip>
> #include <fstream>
> using namespace std;
>
> #define BUFFER_SIZE 1500
> #define INPUT_FILE_NAME "in.txt"
>
> void foo ()
> {
> char cbuffer[BUFFER_SIZE];
> ifstream fs (INPUT_FILE_NAME);
>
> fs.clear();
> fs.seekg (0, ios::beg);
>
> while (!fs.eof())
> {
> fs.read (cbuffer, sizeof(cbuffer));
> cout << "rdstate() = 0x" << hex << fs.rdstate() << dec <<
> "; gcount() = " << fs.gcount() << endl;
> }
> cout << "rdstate() = 0x" << hex << fs.rdstate() << dec << endl; }
>
> int main ()
> {
> foo ();
> return 0;
> }
>
> ----------------------
>
>
> Test input file can be seen at
> http://groups.google.com/group/test-av/msg/0c4d3da487594ab7
>
>
> Output for g++ (Cygwin)
> --------------------
> rdstate() = 0x6; gcount() = 1499
> rdstate() = 0x6
> -------------------
> It seems that behavior of g++ is wrong here.
This is:
PR libstdc++/20806 & PR libstdc++/21286
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20806
It is fixed in 4.x.
Danny
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/