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


"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


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