This is the mail archive of the
libstdc++@sourceware.cygnus.com
mailing list for the libstdc++ project.
ostringstream problem
- To: libstdc++@sourceware.cygnus.com
- Subject: ostringstream problem
- From: Edward C Morgan <ecmorgan@lucent.com>
- Date: Wed, 18 Aug 1999 16:34:03 -0400
- Organization: 53885100
I'm having a problem using the ostringstream class. When I use it
directly everything works
out ok, but if I inherit it into another class, I get a segmentation
fault:
foo.C:
#include <sstream>
class Foo : public ostringstream {
public:
Foo() : ostringstream() {}
~Foo() {}
};
int
main()
{
#ifdef FOO
Foo yy;
#else
ostringstream yy;
#endif
yy << "Hello world\n";
return(0);
}
build:
LIBSTDC=/tmp1/ecm/libstdc++
GCCDIR=/tmp1/ecm/gcc/bin
set -x
${GCCDIR}/g++ -I${LIBSTDC}/include/g++-v3 -g -Wall -Wno-reorder
-L${LIBSTDC}/lib -DFOO foo.C -o fooBad
${GCCDIR}/g++ -I${LIBSTDC}/include/g++-v3 -g -Wall -Wno-reorder
-L${LIBSTDC}/lib foo.C -o fooGood
Here's the output of one of the fooBad compile with the -v option added:
$ ${GCCDIR}/g++ -v -I${LIBSTDC}/include/g++-v3 -g -Wall -Wno-reorder
-L${LIBSTDC}/lib -DFOO foo.C -o fooBad
Reading specs from
/tmp1/ecm/gcc/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95/specs
gcc version 2.95 19990728 (release)
/tmp1/ecm/gcc/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95/cpp -lang-c++ -v
-I/tmp1/ecm/libstdc++/include/g++-v3 -D__GNUC__=2 -D__GNUG__=2
-D__GNUC_MINOR__=95 -D__cplusplus -Dsparc -Dsun -Dunix -D__svr4__
-D__SVR4 -D__sparc__ -D__sun__ -D__unix__ -D__svr4__ -D__SVR4 -D__sparc
-D__sun -D__unix -Asystem(unix) -Asystem(svr4) -D__EXCEPTIONS -g -Wall
-Wno-reorder -D__GCC_NEW_VARARGS__ -Acpu(sparc) -Amachine(sparc) -DFOO
foo.C /tmp/ccoeNyD3.ii
GNU CPP version 2.95 19990728 (release) (sparc)
#include "..." search starts here:
#include <...> search starts here:
/tmp1/ecm/libstdc++/include/g++-v3
/tmp1/ecm/gcc/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95/../../../../include/g++-3
/usr/local/include
/tmp1/ecm/gcc/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95/../../../../sparc-sun-solaris2.5.1/include
/tmp1/ecm/gcc/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95/include
/usr/include
End of search list.
The following default directories have been omitted from the search
path:
End of omitted list.
/tmp1/ecm/gcc/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95/cc1plus
/tmp/ccoeNyD3.ii -quiet -dumpbase foo.cc -g -Wall -Wno-reorder -version
-o /tmp/ccTKqw1d.s
GNU C++ version 2.95 19990728 (release) (sparc-sun-solaris2.5.1)
compiled by GNU C version 2.95 19990728 (release).
/tmp1/ecm/gcc/sparc-sun-solaris2.5.1/bin/as -V -Qy -s -o
/tmp/ccS4qcB7.o /tmp/ccTKqw1d.s
GNU assembler version 2.9.5 (sparc-sun-solaris2.5.1) using BFD version
2.9.5.0.6
/tmp1/ecm/gcc/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95/collect2 -V -Y
P,/usr/ccs/lib:/usr/lib -Qy -o fooBad
/tmp1/ecm/gcc/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95/crt1.o
/tmp1/ecm/gcc/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95/crti.o
/usr/ccs/lib/values-Xa.o
/tmp1/ecm/gcc/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95/crtbegin.o
-L/tmp1/ecm/libstdc++/lib
-L/tmp1/ecm/gcc/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95
-L/tmp1/ecm/gcc/sparc-sun-solaris2.5.1/lib -L/usr/ccs/bin -L/usr/ccs/lib
-L/tmp1/ecm/gcc/lib /tmp/ccS4qcB7.o -lstdc++ -lm -lgcc -lc -lgcc
/tmp1/ecm/gcc/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95/crtend.o
/tmp1/ecm/gcc/lib/gcc-lib/sparc-sun-solaris2.5.1/2.95/crtn.o
GNU ld version 2.9.5 (with BFD 2.9.5.0.6)
Supported emulations:
elf32_sparc
$ ./fooBad
Segmentation Fault
--
=========================================
Edward C. Morgan
Email: ecmorgan@lucent.com
Do not boast about tomorrow, For you
do not know what a day may bring forth.
=========================================