Message-ID: <319BC3B9.297A@public1.guangzhou.gd.cn> Date: Fri, 17 May 1996 09:09:29 +0900 From: Wang TianXing Organization: No Organization MIME-Version: 1.0 To: Dieter Demerre CC: djgpp AT delorie DOT com Subject: Re: bug in fstream ? (V2) for in-out files ? References: <319746C1 DOT 41C67EA6 AT cs DOT kuleuven DOT ac DOT be> Content-Type: text/plain; charset=gb2312 Content-Transfer-Encoding: 7bit Dieter Demerre wrote: > > A couple of months ago I installed DJGPP for I wanted to compile > my program with it. Just last weekend I found that not all objects > behave like they do in BC3.1. > I hereby include my testprogram (partly) that tries to read from > a file but also write to it. > > I find that whenever I open the file to write in it, the file is > renewed, while this is NOT done in Borland C++ nor in > the C++ compiler we have here on the VAX- and ALPHA-machines. > > Did I do anything wrong ? Yes, you were right. The libraries are buggy. This problem popped up a few days ago. The solution is to change the following lines in \djgpp\gnu\libgplus.271\libio\filebuf.cc: if ((mode & (int)ios::trunc) || ((!(mode & (int)ios::app)) && (mode & (int)ios::out))) posix_mode |= O_TRUNC; to: if ((mode & (int)ios::trunc) || ((!(mode & int(ios::app|ios::in))) && (mode & (int)ios::out))) posix_mode |= O_TRUNC; and update libgpp.a, libiostr.a, and libstdcx.a. --- Wang TianXing