From -3823035688850420090
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,53d56717e82ab663
X-Google-Attributes: gidf78e5,public
From: drew@revolt.poohsticks.org (Drew Eckhardt)
Subject: Re: cout << null pointers
Date: 2000/07/09
Message-ID: <oag5k8.one.ln@revolt.poohsticks.org>#1/1
X-Deja-AN: 643939042
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
References: <39656D42.E049FCAA@ix.netcom.com>
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
X-Complaints-To: abuse@demon.net
X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au
X-Trace: mail2news.demon.co.uk 963065850 mail2news:1953 mail2news mail2news.demon.co.uk
Organization: Poohsticks Taoists; Boulder, CO, USA
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
NNTP-Posting-Date: Fri, 07 Jul 2000 18:29:15 CDT
Newsgroups: comp.std.c++

In article <39656D42.E049FCAA@ix.netcom.com>,
Paul Meyerholtz  <pholtz@ix.netcom.com> wrote:

>char * p = 0;

>cout << p << "\n\n";

>However, the handling of "cout << p" seems to cause problems for most
>computers, with results from segment faults to garbage output. 

Dereferencing a NULL pointer is undefined, which means the code 
could handle it gracefully, kill the program, crash the computer, 
reformat the hard disk, or make daemons fly out your nose.....

>Is there anything in the standard about this?  Should cout check for the
>null pointer? 

It would be nice if ostream &operator<<(const char*) did something 
sensible (like print "null"), but isn't required.
-- 
--
<a href="http://www.poohsticks.org/drew/">Home Page</a>
For those who do, no explanation is necessary.
For those who don't, no explanation is possible.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]




