This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ 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: cerr and NULL terminates program + string::find() weird results


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


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