This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Core dump constructing a C++ string with NULL
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@gmail.com> wrote:
> On Fri, Jan 14, 2011 at 11:38, Ian Lance Taylor <iant@google.com> wrote:
>> Tom Browder <tom.browder@gmail.com> 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
>