C++ String Bug
Karl Nelson
kenelson@ece.ucdavis.edu
Fri Sep 18 15:38:00 GMT 1998
While tracing down an error in the Gtk-- source (a C++ widget library), I
discovered that a certain call resulted in a segfault under the condition
of passing a NULL pointer to it. I traced it back to the string header
files. Any passing of a (char*)0 to a function which takes type string
resulted on a seg fault on my out of the box Redhat 5.1 system using
egcs.
The full trace of the crash leads to the file /usr/include/g++/std/bastring.h
somewhere arround...
basic_string& assign (const charT* s)
{ return assign (s, traits::length (s)); }
Example:
#include <string>
int foo(const string &bar)
{ return 1;
}
main()
{foo((char*)NULL);
}
To whom should this bug or patches to fix this bug be submitted? I
am not on this list so be sure to CC me a copy of your reply.
Thank you for your time.
--Karl
More information about the Gcc-bugs
mailing list