Thread View: gnu.g++.lib.bug
1 messages
1 total messages
Started by bilmes
Tue, 01 Sep 1992 08:24
libg++ 2.2 bug in ifstream: :get(char*,int,char)
Author: bilmes
Date: Tue, 01 Sep 1992 08:24
Date: Tue, 01 Sep 1992 08:24
75 lines
3782 bytes
3782 bytes
The following program:
-----------------------------------------------------------------------
#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>
main() {
char buffer[512];
ifstream ifile("foo");
if (!ifile)
exit(1);
while (!ifile.get(buffer,512,'\n').eof()) {
char c;
if (ifile.get(c) && c != '\n') {
cerr << "input truncated\n";
}
cout << buffer << '\n';
}
}
-----------------------------------------------------------------------
with file 'foo' as:
-----------------------------------------------------------------------
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
cccccccccccccccccccccccccccccccccccccccccc
dddddddddddddddddddddddddddddddddddddddddd
ffffffffffffffffffffffffffffffffffffffffff
gggggggggggggggggggggggggggggggggggggggggg
-----------------------------------------------------------------------
produces:
-----------------------------------------------------------------------
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
cccccccccccccccccccccccccccccccccccccccccc
dddddddddddddddddddddddddddddddddddddddddd
...
-----------------------------------------------------------------------
i.e. empty lines continue forever. It seems like get(), when given an empty
input line, sets the error state in the class which causes future get() calls
to do nothing.
gcc -v -o bla{,.cc} -lg++
Reading specs from /usr/local/lib/gcc-lib/mips-dec-ultrix4.2/2.2.2/specs
gcc version 2.2.2
/usr/local/lib/gcc-lib/mips-dec-ultrix4.2/2.2.2/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__ANSI_COMPAT -DMIPSEL -DR3000 -DSYSTYPE_BSD -D_SYSTYPE_BSD -Dbsd4_2 -Dhost_mips -Dmips -Dultrix -Dunix -D__ANSI_COMPAT -D__MIPSEL__ -D__R3000__ -D__SYSTYPE_BSD__ -D___SYSTYPE_BSD__ -D__bsd4_2__ -D__host_mips__ -D__mips__ -D__ultrix__ -D__unix__ -D__ANSI_COMPAT -D__MIPSEL -D__R3000 -D__SYSTYPE_BSD -D___SYSTYPE_BSD -D__bsd4_2 -D__host_mips -D__mips -D__ultrix -D__unix -I/usr/local/lib/gcc-lib/m
ips-dec-ultrix4.2/2.2.2/lib/g++-include -D__LANGUAGE_C_PLUS_PLUS__ -D__LANGUAGE_C_PLUS_PLUS -D__LANGUAGE_C__ -D__LANGUAGE_C -DLANGUAGE_C bla.cc /usr/tmp/cca18277.i
GNU CPP version 2.2.2 [AL 1.1, MM 19] DECstation running ultrix
/usr/local/lib/gcc-lib/mips-dec-ultrix4.2/2.2.2/cc1plus /usr/tmp/cca18277.i -quiet -dumpbase bla.cc -version -o /usr/tmp/cca18277.s
GNU C++ version 2.2.2 [AL 1.1, MM 19] DECstation running ultrix compiled by GNU C version 2.2.2.
as -nocpp -EL -v -o bla.o /usr/tmp/cca18277.s
/usr/lib/cmplrs/cc/as0 -v -G 8 -EL -g0 -O1 /usr/tmp/cca18277.s -o /tmp/ctmaa18280 -t /tmp/ctmsta18280
as0: main
0.0u 0.1s 0:00 20% 65+47k 2+8io 18pf+0w
/usr/lib/cmplrs/cc/as1 -v -G 8 -p0 -EL -g0 -O1 /tmp/ctmaa18280 -o bla.o -t /tmp/ctmsta18280
as1: main
0.0u 0.2s 0:01 25% 103+66k 2+1io 36pf+0w
/usr/local/lib/gcc-lib/mips-dec-ultrix4.2/2.2.2/mips-tfile -v -o bla.o /usr/tmp/cca18277.s
mips-tfile version 2.2.2 [AL 1.1, MM 19] DECstation running ultrix
/usr/local/lib/gcc-lib/mips-dec-ultrix4.2/2.2.2/ld -EL -o bla /usr/lib/cmplrs/cc/crt0.o -L/usr/local/lib/gcc-lib/mips-dec-ultrix4.2/2.2.2 -L/usr/lib/cmplrs/cc -L/usr/lib/cmplrs/cc -L/usr/local/lib bla.o -lg++ -lgcc -lc -lgcc
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