🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #3551

Re: Semantics of "new foo[0]"

#3551
From: Fergus Henderson
Date: Thu, 29 Feb 1996 16:00
45 lines
2301 bytes
clamage@Eng.sun.com (Steve Clamage) writes:

>mgb@kronecker.mitre.org (G. Mike Butler D054) writes:
>>According to the ARM section 5.3.3:
>>     "operator new() can be called with the argument
>>      zero.  Repeated such calls return pointers to
>>      distinct objects."  
>     
>>But when I execute the following:
[...]
>>      foo *p = new foo[0];
>>      foo *q = new foo[0];
[...]
>>I get
>>    0x338d8 0x338e8
>
>>While these are distinct pointers, the pointers refer to overlapping
>>objects.
>
>No, they don't.

You're right, but there *is* a contraction in the draft standard.

5.3.4[expr.new]/8 says "... the allocation function is called to allocate
an array with no elements", but 8.3.4[dcl.array]/1 says "An object of
array type contains a contiguously allocated non-empty set of N sub-objects".

I think that the adjective "non-empty" should be deleted from 8.3.4/8;
it already states in 8.3.4/1 that array bounds in array type declarations
must be greater than zero.

--
Any mail to me between Feb 24th and 27th may have gone to the bit bucket
(#&$^@$!# mail software silently ignored disk full error).  Please resend.
(comp.std.c++ articles were not affected, so no need to resend those.)
Fergus Henderson             	WWW: http://www.cs.mu.oz.au/~fjh
fjh@cs.mu.oz.au              	PGP: finger fjh@128.250.37.3


[ comp.std.c++ is moderated.  To submit articles: Try just posting with your
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu
]
Technical Details
Message-ID: <4h3ij3$nva@mulga.cs.mu.OZ.AU>
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage
References: <MGB.96Feb27175316@kronecker.mitre.org> <4h1up3$l69@engnews1.Eng.Sun.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage
From: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
Newsgroups: comp.std.c++
Subject: Re: Semantics of "new foo[0]"
Date: 29 Feb 1996 16:00:40 GMT
Organization: Comp Sci, University of Melbourne
Approved: clamage@eng.sun.com (comp.std.c++)
Message-ID: <4h3ij3$nva@mulga.cs.mu.OZ.AU>
References: <MGB.96Feb27175316@kronecker.mitre.org> <4h1up3$l69@engnews1.Eng.Sun.COM>
NNTP-Posting-Host: taumet.eng.sun.com
Content-Type: text
X-Nntp-Posting-Host: munta.cs.mu.oz.au
Content-Length: 1330
X-Lines: 37
Originator: clamage@taumet