cerr and NULL terminates program + string::find() weird results
Anibal Jodorcovsky
anibal@intelerad.com
Wed Oct 16 05:08:00 GMT 2002
It surely does! :-)
What I don't understand is how this 'undefined behaviour' is ok.
How can the program just exit? I've seen other implementations that at least
they print a (null) or something like that. I don't think it's too
outrageous to ask for something like that. Imagine if you're passing a char*
around and because of one bug somewhere it gets assigned to NULL and then
cerr gets called, wham! the program silently exits, no core, nothing...
Anyway, I'll be trying to guard my cerr with if !null but I can see how
someone might forget and...
-Anibal
PS: thanks for the reply :-)
----- Original Message -----
> Anibal Jodorcovsky <anibal@intelerad.com> writes:
>
> [...]
>
> | const char* const d = NULL;
>
> | std::cerr << "d is " << d << std::endl;
>
> This invokes an undefined behaviour.
>
> -- Gaby
More information about the Libstdc++
mailing list