Thread View: gnu.g++.lib.bug
1 messages
1 total messages
Started by Doug Moore
Tue, 14 Apr 1992 03:15
bottomless recursion in stream output
Author: Doug Moore
Date: Tue, 14 Apr 1992 03:15
Date: Tue, 14 Apr 1992 03:15
63 lines
2976 bytes
2976 bytes
(previous posted inadvertantly to bug-g++)
Consider the following program:
---- cut here ---------
#include <iostream.h>
main()
{
for(int i = 0 ; i < 396 ; i++)
{
cerr << "i = " << i << "\n";
cerr << "AAAAAAAAAAAA\n";
}
}
---- cut here ---------
Seems innocent, doesn't it?
Well, if one compiles it with g++2.1*, using a version of libg++-2.0
compiled with g++2.1* on a sparc2, sunos 4.1, Sun loader, collect2,
and one runs it, it dies with a bottomless recursion. The last thing printed is
i = 395
and the death occurs in the attempt to print the newline at the end of
that line. Significantly, that newline happens to be the 8193rd
character of output produced by this program.
The bottomless recursion has the following (partial) backtrace as it
begins its descent into the void:
#0 filebuf::overflow (this=0x1a5f8, c=10) at filebuf.C:213
#1 0x11674 in streambuf::sputc (this=0x1a5f8, c=10)
at /marsh/comp212/gnu/libg++-2.0/libg++/iostream/streambuf.h:278
#2 0x5718 in filebuf::overflow (this=0x1a5f8, c=10) at filebuf.C:261
#3 0x11674 in streambuf::sputc (this=0x1a5f8, c=10)
at /marsh/comp212/gnu/libg++-2.0/libg++/iostream/streambuf.h:278
#4 0x5718 in filebuf::overflow (this=0x1a5f8, c=10) at filebuf.C:261
#5 0x1199c in streambuf::sputn (this=0x1a5f8, s=0x2299 "", n=1) at streambuf.C:46
#6 0x68d0 in filebuf::sputn (this=0x1a5f8, s=0x2298 "\n", n=1) at filebuf.C:546
#7 0xa98c in operator<< (stream=@0x1a694, s=0x2298 "\n") at iostream.C:506
#8 0x2310 in main () at bug.cc:7
and here is the (routine) compiler output from compiling the program:
c++ -g -Wall -v bug.cc
Reading specs from /marsh/comp212/lib/gcc-lib/sun4/2.1/specs
gcc version 2.1
/marsh/comp212/lib/gcc-lib/sun4/2.1/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 -g -Wall bug.cc /usr/tmp/cca25242.i
GNU CPP version 2.1 (sparc)
/marsh/comp212/lib/gcc-lib/sun4/2.1/cc1plus /usr/tmp/cca25242.i -quiet -dumpbase bug.cc -g -Wall -version -o /usr/tmp/cca25242.s
GNU C++ version 2.1 (sparc) compiled by GNU C version 2.1.
as -o bug.o /usr/tmp/cca25242.s
/marsh/comp212/lib/gcc-lib/sun4/2.1/ld -e start -dc -dp /lib/crt0.o -L/marsh/comp212/lib/gcc-lib/sun4/2.1/ -L/marsh/comp212/lib/ bug.o -lg++ -lm -lgcc -lc -lg -lgcc
Compilation finished at Mon Apr 13 17:48:29
I wish I could suggest a patch, but the code is too opaque for me.
Doug Moore (dougm@cs.rice.edu)
* with Tiemann and Stump patches applied
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