Core dump constructing a C++ string with NULL

Tom Browder
Sat Jan 15 12:33:00 GMT 2011

On Fri, Jan 14, 2011 at 11:48, Brian Budge <> wrote:
> Nothing is immune to pointer problems that violate preconditions.
> I'm curious; is it really easier to modify the compiler than to write
> your string construction as I proposed?

Here's the situation:

open source library A ( with many kloc of C code by
many people over decades
  - possible lots of hidden null ptr string bugs remaining (one found
just recently)

open source library A++ wrapping lib A

user of A++ gets stuck and finds one of the null char* bugs as it is
used to construct a C++ string

user of A++ can't fix A++

Now consider my original suggestion with this modification:

  consider it a built-in try {} catch {} block and trap the exception
and return an empty string as well as report the problem to stderr

The compiler option might be something like:


Now the user may be able to carry on and he can also report the bug.



More information about the Gcc-help mailing list