🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: gnu.g++.lib.bug
1 messages
1 total messages Started by Brendan Kehoe Wed, 14 Oct 1992 02:19
[laurenz@juno.neuroinformatik.ruhr-uni-bochum.de : gcc-2.2.2 libg++-2.2 stream bugs]
#296
Author: Brendan Kehoe
Date: Wed, 14 Oct 1992 02:19
97 lines
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 -------
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads