From 4073605707708736017
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,53d56717e82ab663
X-Google-Attributes: gidf78e5,public
From: Anders Pytte <anders@milkweed.com>
Subject: Re: cout << null pointers
Date: 2000/07/09
Message-ID: <B58BC03A.6E70%anders@milkweed.com>#1/1
X-Deja-AN: 644039001
Content-transfer-encoding: 7bit
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
References: <39656D42.E049FCAA@ix.netcom.com> <B58BAAC8.6E61%anders@milkweed.com>
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 963088257 mail2news:16957 mail2news mail2news.demon.co.uk
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
User-Agent: Microsoft-Outlook-Express-Macintosh-Edition/5.02.2022
Mime-version: 1.0
NNTP-Posting-Date: Fri, 07 Jul 2000 17:11:55 EDT
Newsgroups: comp.std.c++

in article B58BAAC8.6E61%anders@milkweed.com, Anders Pytte at
anders@milkweed.com wrote on 7/8/00 7:49 AM:

> in article 39656D42.E049FCAA@ix.netcom.com, Paul Meyerholtz at
> pholtz@ix.netcom.com wrote on 7/8/00 5:08 AM:
> 
>> I have found an inconsistent output by various compilers of the following:
>> 
>> char * p = 0;
>> cout * q = "";
>> 
>> cout << p << "\n\n";
>> cout << q;
>> 

[snip]

> In the above, "cout << p" says, print the c string stored at address 0,
> while "cout << q" says, print a c string of zero length. Why should these
> produce the same output?

This was a bit sloppy of me considering the heated discussion of NULL next
door. It would be more correct to say simply that dereference of a NULL
pointer is undefined, although on a typical implementation it amounts to
accessing data stored at location 0. This is probably what happened when
Paul used Metrowerks C++ on the Mac.

Anders.

-- 
Anders Pytte                                   Milkweed Software
PO Box 32                                  voice: (802) 586-2545
Craftsbury, VT 05826                  email: anders@milkweed.com

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




