This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: cerr and NULL terminates program + string::find() weird results
- From: "Anibal Jodorcovsky" <anibal at intelerad dot com>
- To: "Gabriel Dos Reis" <gdr at integrable-solutions dot net>
- Cc: <libstdc++ at gcc dot gnu dot org>, <neelin at intelerad dot com>, "Kent Tse" <kent at intelerad dot com>
- Date: Wed, 16 Oct 2002 08:08:51 -0400
- Subject: Re: cerr and NULL terminates program + string::find() weird results
- References: <002d01c2720c$1f571550$1201a8c0@jaucho> <m3y993v6mb.fsf@soliton.integrable-solutions.net>
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