Am not sure if you'd consider this a bug or not since iostream details are sketchy, but I have 3 other C++ compilers that handle the same code without failing while djgpp doesn't seem to. Just downloaded the djgpp compiler files again so I assume I am working with the latest version. A code example is given below.
If I run a program with the following code and simply hit enter at the command prompt with no characters on the line, the failbit gets set. Both versions of get below show the failbit set after calling them. There's code in istream.tcc that says:
if (!_M_gcount)
this->setstate(ios_base::failbit);
The state of the stream then becomes corrupt and no more input can get sent to the program. I don't think get(char_type* __s, streamsize __n, char_type __delim)
should return a fail here unless the next character in the stream is not the __delim character.
As I mentioned, I have three other C++ compiler that allow me to use the following code and enter either a string or simply a carriage return without failing. When I try this code with djgpp, it fails and goes into an infinite loop, never reading any more input from cin. Would love to see this fixed to be more consistent with the other compilers and so I don't have to set up a special case for djgpp iostream handling in all my files using get. Thank you.
char temp[256];
char ctemp;
bool done = false;
while (done == false)
{
cout << endl;
cout << ">> ";
cin.get (temp, 255, '\n');
cin.get (ctemp);
cout << temp << endl;
//...
//code here to do some work based on each input string entered by user and
//to set done to true when finished (for example when user types exit).
}