From: James Coram Newsgroups: comp.os.msdos.djgpp Subject: Trouble with a binary ofstream Date: Sat, 23 Aug 1997 07:37:40 -0700 Organization: CAIS Internet Lines: 37 Message-ID: <33FEF5B4.BFC007BE@pacificnet.net> NNTP-Posting-Host: pm3a-23.pacificnet.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk I am having trouble using a binary ofstream with DJGPP. I get different results depending on how I compile my program. When I compile the following code fragment with: gxx test.cc The resulting a.exe fails, aborting at the final assertion. However, if I compile with: gxx -O3 test.cc The resulting a.exe runs correctly and creates the file "out". Note also that if I do not use the ios::binary switch, it works either way. As far as I know I am running the lastest installation of DJGPP. Am I doing something wrong, or can others reproduce this bug? Thanks /*test.cc*/ #include #include #include #include #include int main() { ofstream os("out", ios::binary); assert(os); assert(!os.bad()); os << "hello" << endl; assert(!os.bad()); return(0); }