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 15 January 2011 14:12, Jonathan Wakely wrote:
> On 15 January 2011 14:05, Tom Browder wrote:
>>
>> ?a g++ extension for a "dyn_string" ("full dynamic string") that has
>> that behavior
>
> How are you going to change a third-party library to use that?!

Wouldn't it be easier to change the code to not pass a null pointer to
a std::string, than to change it to use a new, incompatible string
class?!

Or just use a helper function to construct your strings:

inline std::string safe_string(const char* s)
{ return s ? s : ""; }

There are many ways to solve this problem portably, but you seem
fixated on making the standard library change to accommodate broken
code.


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