[gnu.g++.lib.bug] Reading last thing from an istream

T.Day@ucl-cs.UUCP (11/27/89)

From: Tim Day <T.Day@uk.ac.ucl.cs>

// Bug or feature ? In libg++ 1.36 using g++ 1.36.1
// I'm think this behaved differently with libg++ 1.35.  A 2.0ism ?
// The problem is that if the last integer is not followed by whitespace
//  the istream will go bad... I'd expect this to happen only on a subsequent
//  attempt to read

#include <stream.h>

main()
{	unlink("foo");
	
	{ostream foo("foo",io_writeonly,a_create);
	foo << 1 << " " << 2 << " " << 3;// No trailing whitespace after 3
	}

	{istream foo("foo",io_readonly,a_useonly);
	int count=0,n;
	while (foo >> n) {cerr << n << " ";count++;}
	cerr << " : " << count << " integers read\n";
	}

	exit(0);
}

// Outputs :
// 1 2  : 2 integers read