Thread View: gnu.g++.lib.bug
2 messages
2 total messages
Started by Doug Moore
Tue, 26 Jan 1993 01:27
2.3: bogus failstate in getline
Author: Doug Moore
Date: Tue, 26 Jan 1993 01:27
Date: Tue, 26 Jan 1993 01:27
47 lines
2665 bytes
2665 bytes
As the following program indicates, when getline is called with a
buffersize of n and n-1 characters are put in the buffer, the state of
the istream is changed to fail. This is inappropriate and contrary to
the behavior of Sun C++. The line in igetline.C that brings this
about is easy to find and remove, but I hesitate. It must be there
for some reason, right?
Program:
====================================================================
#include <iostream.h>
main()
{
char buf[10];
cin.getline(buf, sizeof(buf));
cout << "Buffer is: " << buf << endl;
cout << "cin state is " << cin.rdstate() << endl;
}
====================================================================
Output compiled with g++, libg++, input "abcdefghijklmnopqrstuvwxyz"
====================================================================
Buffer is: abcdefghi
cin state is 2
====================================================================
Output compiled with Sun C++, same input
====================================================================
Buffer is: abcdefghi
cin state is 0
====================================================================
Verbose compiler output:
====================================================================
g++ -o a.out -Wall -v bug.cc
Reading specs from /blossom/lib/gcc-lib/sun4/2.3.3/specs
gcc version 2.3.3
/blossom/lib/gcc-lib/sun4/2.3.3/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__sparc -D__sun -D__unix -Wall bug.cc /usr/tmp/cca27304.i
GNU CPP version 2.3.3 (sparc)
/blossom/lib/gcc-lib/sun4/2.3.3/cc1plus /usr/tmp/cca27304.i -quiet -dumpbase bug.cc -Wall -version -o /usr/tmp/cca27304.s
GNU C++ version 2.3.3 (sparc) compiled by GNU C version 2.3.3.
as -o /usr/tmp/cca273041.o /usr/tmp/cca27304.s
/blossom/lib/gcc-lib/sun4/2.3.3/ld -e start -dc -dp -o a.out /lib/crt0.o -L/blossom/lib/gcc-lib/sun4/2.3.3 -L/blossom/lib /usr/tmp/cca273041.o -lg++ -lgcc -lc -lgcc
====================================================================
Both the compiler and library have been patched a bit. The system is
sunos 4.1.2, on a sparc.
Doug Moore
(dougm@cs.rice.edu)
Re: 2.3: bogus failstate in getline
Author: bothner
Date: Tue, 26 Jan 1993 02:26
Date: Tue, 26 Jan 1993 02:26
17 lines
1100 bytes
1100 bytes
> As the following program indicates, when getline is called with a > buffersize of n and n-1 characters are put in the buffer, the state of > the istream is changed to fail. This is inappropriate and contrary to > the behavior of Sun C++. I'm following the ANSI draft (revision 4): Sets: failbit if it stops because it has extracted len-1 characters. A comments says: Setting failbit in these circumstances is a change from the AT&T library, but seems sensible. ... If you disagree, don't argue with me; argue with Jerry Schwarz (jss@lucid.com). --Per Bothner Cygnus Support bothner@cygnus.com
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