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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?  Or, even better, if you
control the code that returns the char*, return "" instead of NULL.

  Brian

On Fri, Jan 14, 2011 at 9:43 AM, Tom Browder <tom.browder@xxxxxxxxx> wrote:
> On Fri, Jan 14, 2011 at 11:38, Ian Lance Taylor <iant@xxxxxxxxxx> wrote:
>> Tom Browder <tom.browder@xxxxxxxxx> writes:
>>
>>> 2.  Isn't a '\0' an empty string in the string context?
>>
>> I thought you were asking about std::string(0), which is quite a
>> different matter from std::string('\0').
>
> What I'm poorly trying to say is that, even if the string is passed a
> null pointer, that appears to be an empty string in the context of a
> string, so an option to accept it as such is not unreasonable.
>
> I understand that the null pointer is probably an error up stream, and
> this might not be portable.  But the whole point of C++ striings I
> thought was to be a safe string immune from pointer problems.
>
> -Tom
>



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux