X-Spam-Check-By: sourceware.org Date: Mon, 16 Oct 2006 09:01:11 +1300 From: Danny Smith Subject: Re: Behavior of ifstream::read() in g++ To: Cygwin Message-id: <000801c6f094$aa5e7160$096d65da@anykey> MIME-version: 1.0 X-Mailer: Microsoft Outlook, Build 10.0.2627 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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 > #include > #include > 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/