This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Core dump constructing a C++ string with NULL


On Fri, Jan 14, 2011 at 11:48, Brian Budge <brian.budge@gmail.com> 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 (http://brlcad.org) 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:

  "--auto-catch-c++-null-string-exception"

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

Regards,

-Tom


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]