From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 8845 invoked from network); 6 May 1998 11:22:07 -0000 Received: from data.tops.net (root@194.162.222.70) by mail2.redhat.com with SMTP; 6 May 1998 11:22:07 -0000 Received: from tops.net (armin@data.tops.net [194.162.222.70]) by data.tops.net (8.8.7/8.8.7) with ESMTP id NAA00637 for ; Wed, 6 May 1998 13:22:01 +0200 Sender: armin@data.tops.net Message-ID: <355047D9.7C4732B5@tops.net> Date: Wed, 06 May 1998 11:22:01 +0000 From: Armin Ollig Organization: tops.NET ISP X-Mailer: Mozilla 4.04 [en] (X11; I; Linux 2.0.33 i586) MIME-Version: 1.0 To: axp-list@redhat.com Subject: Bug in g++ ? (binary writing to file) Content-Type: multipart/mixed; boundary="------------BF3AD0FF3EC55C051F38B3F7" This is a multi-part message in MIME format. --------------BF3AD0FF3EC55C051F38B3F7 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit ok, here's a very short and simple proggy for writing some numbers to a file *binary*. The output is a double.dat file with a size of 0 bytes, hence nothing at all was written. The proggy is from an (ansi) C++ book. It works as expected with Borlands C++ 5.0 under $95. If i debug the problem i get: 0x40066828 in ofstream::open () at fstream.h:87 fstream.h:87: No such file or directory. Is this a bug or am i just mad ??? However, it works without a problem if i use ascii io, but refuses to work with "ios::binary". I compile with "g++ -o foo01 foo01.c++". My system is a RH5; PC164 21164; Kernel 2.0.33; gcc version 2.7.2.3 ...what gdb reports: (gdb) list 1 #include 2 #include 3 #include 4 void main(void) 5 { 6 ofstream target; 7 target.open("double.dat", ios::binary); 8 if (!target) 9 { 10 cerr << "could not open file for writing" << endl; (gdb) break 7 Breakpoint 1 at 0x8048689: file foo01.c++, line 7. (gdb) run Starting program: /home/armin/foo01 step Breakpoint 1, main () at foo01.c++:7 7 target.open("double.dat", ios::binary); (gdb) step 0x40066828 in ofstream::open () at fstream.h:87 fstream.h:87: No such file or directory. (gdb) step Program exited normally. (gdb) ...my programm: #include #include #include void main(void) { ofstream target; target.open("double.dat", ios::binary); if (!target) { cerr << "could not open file for writing" << endl; exit(-1); } double d=1.0; for (int i=0; i < 20; i++, d*=1.1) target.write((char *) &d, sizeof(d)); target.close () ; // if you want... } any suggestions welcome :)) thanks in advance, best regards, --armin -- --------------------------------------------------------------------- | Armin Ollig UNIX Systems Administration armin@tops.net | | | | If god is dead who will save the queen ? | --------------------------------------------------------------------- --------------BF3AD0FF3EC55C051F38B3F7 Content-Type: message/rfc822 Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-ID: <354F15C6.AAEB22@tops.net> Date: Tue, 05 May 1998 13:36:06 +0000 From: Armin Ollig Organization: tops.NET ISP X-Mailer: Mozilla 4.04 [en] (X11; I; Linux 2.0.33 i586) MIME-Version: 1.0 To: axplist@redhat.com Subject: Bug in g++ ? (binary writing to file) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit ok, here's a very short and simple proggy for writing some numbers to a file *binary*. The output is a double.dat file with 0 bytes of lenth, hence nothing at all was written. The proggy is from an (ansi) C++ book. If i debug the problem i get: 0x40066828 in ofstream::open () at fstream.h:87 fstream.h:87: No such file or directory. Is this a bug or am i just mad ??? However, it works without a problem if i use ascii io, but refuses to work with ios::binary. I compile with "g++ -o foo01 foo01.c++". My system is a RH5 PC164 21164; Kernel 2.0.33; gcc version 2.7.2.3 ...what gdb reports: (gdb) list 1 #include 2 #include 3 #include 4 void main(void) 5 { 6 ofstream target; 7 target.open("double.dat", ios::binary); 8 if (!target) 9 { 10 cerr << "could not open file for writing" << endl; (gdb) break 7 Breakpoint 1 at 0x8048689: file foo01.c++, line 7. (gdb) run Starting program: /home/armin/foo01 step Breakpoint 1, main () at foo01.c++:7 7 target.open("double.dat", ios::binary); (gdb) step 0x40066828 in ofstream::open () at fstream.h:87 fstream.h:87: No such file or directory. (gdb) step Program exited normally. (gdb) ...my programm: #include #include #include void main(void) { ofstream target; target.open("double.dat", ios::binary); if (!target) { cerr << "could not open file for writing" << endl; exit(-1); } double d=1.0; for (int i=0; i < 20; i++, d*=1.1) target.write((char *) &d, sizeof(d)); } thanks in advance, best regards, --armin -- --------------------------------------------------------------------- | Armin Ollig UNIX Systems Administration armin@tops.net | | | | If god is dead who will save the queen ? | --------------------------------------------------------------------- --------------BF3AD0FF3EC55C051F38B3F7--