From 2209858697290655944
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,8372ae6de42be399
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 2004-02-23 09:30:20 PST
Return-Path: <devnull@stump.algebra.com>
X-Authentication-Warning: mulga.cs.mu.OZ.AU: fjh set sender to devnull@stump.algebra.com using -f
Path: archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!crtntx1-snh1.gtei.net!news.gtei.net!newsfeed1.easynews.com!easynews.com!easynews!elnk-pas-nf1!newsfeed.earthlink.net!pd7cy1no!shaw.ca!news.alt.net!comp-std-cpp-robomod!not-for-mail
X-Robomod: STUMP, ichudov@algebra.com (Igor Chudov)
Delivered-To: std-c++@ucar.edu
From: Steve Clamage <stephen.clamage@sun.com>
Newsgroups: comp.std.c++
Subject: Re: Array of size 0
Organization: Sun Microsystems, Inc.
Message-ID: <c1dal8$3qs$1@news1nwk.SFbay.Sun.COM>
References: <403601F6.8010706@ircad.u-strasbg.fr> <c15mlg$pdl$1@news1nwk.SFbay.Sun.COM> <m3y8qwp6uy.fsf@merlin.cs.tamu.edu>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news1nwk.SFbay.Sun.COM 1077554664 3932 129.146.79.208 (23 Feb 2004 16:44:24 GMT)
X-Complaints-To: usenet@news1nwk.sfbay.sun.com
NNTP-Posting-Date: Mon, 23 Feb 2004 16:44:24 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; U; SunOS sun4u; en-US; rv:1.4) Gecko/20031128
X-Accept-Language: en-US, en
X-Spam-Checker-Version: SpamAssassin 2.60-mulga_r1 (1.212-2003-09-23-exp) on 
	mulga.cs.mu.OZ.AU
X-Spam-Status: No, hits=0.0 required=5.2 tests=none autolearn=no 
	version=2.60-mulga_r1
Approved: Fergus Henderson <fjh@cs.mu.oz.au>, moderator of comp.std.c++
Date: Mon, 23 Feb 2004 11:26:27 CST
Lines: 34
Xref: archiver1.google.com comp.std.c++:1207

Gabriel Dos Reis wrote:
> stephen.clamage@sun.com (Steve Clamage) writes:
> 
> | Now consider
> | 	int* myArray = new int[n];
> | If n were not allowed to be zero, the runtime system would have to
> | check for zero elements and generate some kind of runtime error,
> | probably an exception. The program would have to check specially for
> | zero size or be prepared to deal with the exception -- perhaps in many
> | places.
> 
> Is that really different from the current behaviour whereby the
> new-expression can throw because of shortage of storage and the
> program has to check?
> 

On limited-resource computers where you expect allocation to fail, there is 
probably little difference.  That is, being able to recover from an 
out-of-memory situation takes careful design and programming anyway.

But for common applications on desktop or data-center computer systems, a failed 
allocation is unusual, and typically there is little you can do to recover. It 
is often reasonable to ignore the out-of-memory exception and let the program 
exit more-or-less gracefully.

-- 
Steve Clamage, stephen.clamage@sun.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://www.jamesd.demon.co.uk/csc/faq.html                       ]



