This is the mail archive of the
libstdc++@sourceware.cygnus.com
mailing list for the libstdc++ project.
Crash when outputting empty string
- To: libstdc++ at sourceware dot cygnus dot com
- Subject: Crash when outputting empty string
- From: Richard Atterer <atterer at informatik dot tu-muenchen dot de>
- Date: Thu, 14 Oct 1999 18:29:53 +0200 (MET DST)
Hello,
I'm having trouble with outputting a zero-length string when using
libstdc++-2.90.6. The program below crashes when f() is called for the
second time. Everything works fine when I use the libstdc++ supplied with
gcc 2.95.1, though:
/* libstd.cc
> /home/richard/gcc-2.95.1/bin/c++ \
-I/home/richard/gcc-2.95.1/libstdc++-2.90.6/include/g++-v3 \
-L/home/richard/gcc-2.95.1/libstdc++-2.90.6/lib -v
Reading specs from
/home/richard/gcc-2.95.1/lib/gcc-lib/i686-pc-linux-gnu/2.95.1/specs
gcc version 2.95.1 19990816 (release)
> /home/richard/gcc-2.95.1/bin/c++ \
-I/home/richard/gcc-2.95.1/libstdc++-2.90.6/include/g++-v3 \
-L/home/richard/gcc-2.95.1/libstdc++-2.90.6/lib -Wall -O libstd.cc
*/
#include <iostream>
#include <string>
string s;
void f() {
cerr << s << 46 << endl;
return;
}
int main() {
f(); // works
f(); // crashes if (s == "")
return 0;
}
I see there's something like this in the 'known bugs' document, but maybe
this example will help you to track down the problem.
Another issue are the warnings which gcc outputs, e.g. whenever you
#include <iostream>. Is there any means by which you can avoid their being
output?
Cheers,
Richard
--
__ _
|_) /| Richard Atterer (currently at Queen's University, Belfast, NI)
| \/¯| http://www.in.tum.de/~atterer/
¯ ´` ¯