[gnu.g++.bug] problem with cin return

wayne@TOUTLE.CS.WASHINGTON.EDU (Wayne Winder) (11/18/89)

Running g++ (1.35.0) on a sun 3, OS3.5

I report this since I'm sure this used to work,
but doesn't with this version.  The following
program gets into an infinite loop when the
standard input is redirected from a file which
does not terminate with a <CR>.

-----------------
#include <stream.h>

main()
{
    char buf[100];
    int i = 0;

    while (cin >> buf) i++;

    cout << "i: " << i << "\n";
}
-----------------

It also does not behave as expected when the
standard input is pushed in via <ctrl-D>.

The return from "cin >> buf" appears to be the
cin reference, which correctly shows eof to be
true when the (redirected) input file does not
end with <CR>.  This correctly returns a <NULL>
when the input file has a terminating <CR>.

Wayne E. Winder
Northwest Lab for Integrated Systems
University of Washington