X-Spam-Check-By: sourceware.org To: cygwin AT cygwin DOT com From: "Alex Vinokur" Subject: Behavior of ifstream::read() in g++ Date: Sun, 15 Oct 2006 06:10:17 +0200 Lines: 81 Message-ID: X-IsSubscribed: yes 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 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. Output for gpp (Djgpp) ------------------- rdstate() = 0x0; gcount() = 1500 rdstate() = 0x0; gcount() = 1500 rdstate() = 0x0; gcount() = 1500 rdstate() = 0x0; gcount() = 1500 rdstate() = 0x0; gcount() = 1500 rdstate() = 0x6; gcount() = 1071 rdstate() = 0x6 ------------------- Output for Microsoft C++ ------------------- rdstate() = 0x0; gcount() = 1500 rdstate() = 0x0; gcount() = 1500 rdstate() = 0x0; gcount() = 1500 rdstate() = 0x0; gcount() = 1500 rdstate() = 0x0; gcount() = 1500 rdstate() = 0x3; gcount() = 1071 rdstate() = 0x3 ------------------- Alex Vinokur email: alex DOT vinokur AT gmail DOT com http://mathforum.org/library/view/10978.html http://sourceforge.net/users/alexvn -- 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/