From 9004333148858866467
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,8366734ec6aad121
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1994-06-07 02:04:06 PST
Newsgroups: comp.std.c++
Path: nntp.gmd.de!xlink.net!howland.reston.ans.net!pipex!uknet!EU.net!uunet!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjh
From: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
Subject: Re: new foo[0]
Message-ID: <9415818.9649@mulga.cs.mu.OZ.AU>
Sender: news@cs.mu.OZ.AU
Organization: Computer Science, University of Melbourne, Australia
References: <CquD6C.LEK@lehman.com>
Date: Tue, 7 Jun 1994 08:59:27 GMT
Lines: 22

eschwarz@shearson.com (Edward Schwarz) writes:

>What, if any, is the difference between 
>
>A)	foo* myfoo0 = new foo[0];
>
>and
>
>B)	foo* myfoo1 = new foo[1];

Yes, there is a difference: after (A), the expression `myfoo0[0]' is not legal,
whereas after (B), the expression `myfoo1[0]' is quite legal.

>The ARM says that A) will retun a pointer to an object, and that
>distinct calls will return distinct objects. This would seem to imply
>that there is no difference between A) and B).

The object which is pointed to by the return value is a zero-length array
of `foo', not a object of type `foo'.

-- 
Fergus Henderson - fjh@munta.cs.mu.oz.au


