Article View: gnu.g++.lib.bug
Article #296[laurenz@juno.neuroinformatik.ruhr-uni-bochum.de : gcc-2.2.2 libg++-2.2 stream bugs]
From: Brendan Kehoe
Date: Wed, 14 Oct 1992 02:19
Date: Wed, 14 Oct 1992 02:19
97 lines
3382 bytes
3382 bytes
------- Start of forwarded message -------
From: laurenz@juno.neuroinformatik.ruhr-uni-bochum.de (Laurenz Wiskott)
Subject: gcc-2.2.2 libg++-2.2 stream bugs
To: bug-gcc@prep.ai.mit.edu
Cc: neef@neuroinformatik.ruhr-uni-bochum.de,
laurenz@neuroinformatik.ruhr-uni-bochum.de
Date: Fri, 9 Oct 92 10:07:15 +0100
Dear 'GNU',
I've great respect for your Organization and like your software very
much. Many thanks for all that.
We are just changing from the AT&T C++ compiler to your gcc-2.2.2 with
the libg++-2.2. And the bugs changes also. I think I've found at least
one bug concerning the file streams. Here follows a simple example:
- ----------------------------------------------------------------------
#include <fstream.h>
main()
{
// the test files test1 and test2 do not yet exist ;
// this behaves as expected ;
ifstream ifile;
ifile.open("test1",ios::in);
cerr << ifile.good() << flush;
ofstream ofile;
ofile.open("test1",ios::out); // the test1 file will be created here ;
ofile << "data1" << flush;
cerr << ofile.good() << flush;
// but it is not possible to open a fstream
// in order to write something onto a file
// after you have tried to open it fruitless for a read access ;
fstream iofile;
iofile.open("test2",ios::in);
cerr << iofile.good() << flush;
iofile.close(); // even with a close() command ;
iofile.open("test2",ios::out);
cerr << iofile.fail() << iofile.good() << flush; // output: 40
iofile << "data2" << flush; // no data in the test2 file ;
// but it works with the AT&T compiler ;
};
- ----------------------------------------------------------------------
The second is more an uncomfortable feature than really a bug I think.
Consider the following two programs.
- ----------------------------------------------------------------------
#include <stream.h>
typedef char arrType;
#define arrSize 16
main()
{
arrType arr[arrSize];
for (int i=0; i<arrSize; i++)
arr[i]=(arrType)i;
cout.write((char *)arr,sizeof(arrType)*arrSize);
// cout.flush();
}
- ----------------------------------------------------------------------
#include <stream.h>
typedef char arrType;
#define arrSize 16
main()
{
arrType arr[arrSize];
cin.read((char*)arr,sizeof(arrType)*arrSize);
for (int i=0; i<arrSize; i++)
cerr << i << " : " << float(arr[i]) << "\n";
}
- ----------------------------------------------------------------------
Compile it to get the executables 'out' and 'in' and pipe the result
of the first to the second: out|in. You can do it with or without the
flush command. The flush seems necessary but as I think it would be
more comfortable if it would not.
Kind regards, Laurenz Wiskott.
------- End of forwarded message -------
Technical Details
Message-ID:
<9210140219.AA00419@cygnus.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!convex!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!cygnus.com!brendanShow Full Headers
Complete Article Headers
Newsgroups: gnu.g++.lib.bug Path: arc1-ca.pugleaf.net!sparky!uunet!convex!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!cygnus.com!brendan From: brendan@cygnus.com (Brendan Kehoe) Subject: [laurenz@juno.neuroinformatik.ruhr-uni-bochum.de : gcc-2.2.2 libg++-2.2 stream bugs] Message-ID: <9210140219.AA00419@cygnus.com> Sender: gnulists@ai.mit.edu Reply-To: brendan@cygnus.com Organization: GNUs Not Usenet Distribution: gnu Date: Wed, 14 Oct 1992 02:19:51 GMT Approved: bug-lib-g++@prep.ai.mit.edu Lines: 98