cerr and NULL terminates program + string::find() weird results

Gabriel Dos Reis gdr@integrable-solutions.net
Wed Oct 16 05:37:00 GMT 2002


"Anibal Jodorcovsky" <anibal@intelerad.com> writes:

| It surely does! :-)
| 
| What I don't understand is how this 'undefined behaviour' is ok.

By definition, anything happening 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 consider that is really a favor -- at least not for me
(hearing my user hat).  How can one distinguish from the string
"(null)" output on std::cerr? 

Sending NULL on a stream is asking for trouble, that is should be
fixed as soon as possible.  Second-guessing what should be printed
isn't a service, IMHO.

| 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...

Oh, maybe dumping core would be a sensible thing to consider and to
do, but I don't buy "(null)". 

-- Gaby



More information about the Libstdc++ mailing list