From -6261341438001716131
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,53d56717e82ab663,start
X-Google-Attributes: gidf78e5,public
From: Paul Meyerholtz <pholtz@ix.netcom.com>
Subject: cout << null pointers
Date: 2000/07/08
Message-ID: <39656D42.E049FCAA@ix.netcom.com>#1/1
X-Deja-AN: 643533683
Content-Transfer-Encoding: 7bit
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
X-Accept-Language: en
X-Server-Date: 7 Jul 2000 05:40:24 GMT
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
Content-Type: text/plain; charset=us-ascii
X-Complaints-To: abuse@demon.net
X-Mail2News-Path: news.demon.net!mulga.cs.mu.oz.au
X-Trace: mail2news.demon.co.uk 962989739 mail2news:11764 mail2news mail2news.demon.co.uk
Organization: MindSpring Enterprises
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
Mime-Version: 1.0
Reply-To: pholtz@ix.netcom.com
Newsgroups: comp.std.c++

I have found an inconsistent output by various compilers of the following:

char * p = 0;
cout * q = "";

cout << p << "\n\n";
cout << q;

Most compilers seem to handle "cout << q" without a problem.  (But I
have heard that Visual C++ 6 fails this test).

However, the handling of "cout << p" seems to cause problems for most
computers, with results from segment faults to garbage output. 
(CodeWarrior for the Mac, which I use, outputs a couple of garbage
characters, but always the same ones).

Why is the output of p and q different?

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

Paul

---
[ 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              ]




