Article View: gnu.g++.lib.bug
Article #4532.3: bogus failstate in getline
From: 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)
Technical Details
Message-ID:
<9301240857.AA27362@cs.rice.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!cs.rice.edu!dougmShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!cs.rice.edu!dougm From: dougm@cs.rice.edu (Doug Moore) Newsgroups: gnu.g++.lib.bug Subject: 2.3: bogus failstate in getline Date: 25 Jan 1993 20:27:44 -0500 Organization: GNUs Not Usenet Lines: 48 Sender: daemon@cis.ohio-state.edu Approved: bug-lib-g++@prep.ai.mit.edu Distribution: gnu Message-ID: <9301240857.AA27362@cs.rice.edu>