Core dump constructing a C++ string with NULL

Jonathan Wakely jwakely.gcc@gmail.com
Fri Jan 14 16:47:00 GMT 2011


On 14 January 2011 16:19, Tom Browder wrote:
>
> How about a compiler option then, something like
> "--allow-c++-null-string-constructor"...

We throw an exception, std::logic_error, indicating a precondition violation.

Silently ignoring a problem and acting as though a different
constructor was called encourages non-portable code.
It's also an additional maintenance burden, for questionable benefit.
I certainly don't want to have to test my changes to std::string twice
with different builds.

If you don't care about portability you're free to modify the code
yourself for your own use.



More information about the Gcc-help mailing list