🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Why no allocator-specific delete?

#3106
From: Fergus Henderson
Date: Thu, 25 Jan 1996 07:40
50 lines
2207 bytes
clamage@Eng.Sun.COM (Steve Clamage) writes:

>David Byrden <100101.2547@compuserve.com>
>writes:
>>Why, in the Septenber draft standard, is an allocator-specific verrion of 
>>'new' provided;
>>
>>20.1.4.4
>>
>>           new(x) T    
>>
>>    returns an X::types<T>::pointer, where x is of an 
>>    allocator type X
>
>You are actually referring to the "placement new" syntax not having a
>corresponding "placement delete" syntax.

No; that's part of the issue, but there is also a question of why
allocators are not required to define an operator delete() function.
If I write

	new (x) T

where x is an allocator, and the constructor for T throws an
exception, does x.deallocate() get called?  According to the
September draft, I don't think it does -- and that is a real
problem.

There also appears to be another problem with

	new (x) T[n];

The supposed semantics of this are

	new((void*)x.template allocate<T>(n)) T[n]

However, that may have undefined behaviour!
The reason is that it may not allocate enough memory.
It is only guaranteed to allocate enough memory to hold
`n' objects of type `T'.  However, the compiler
need additional space for ``array allocation overhead''
(see [expr.new]).

--
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.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <9601250655.8394@mulga.cs.mu.OZ.AU>
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
References: <4dvid8$460@news.bridge.net> <4e0u1s$5fv@engnews1.Eng.Sun.COM>

Show Full Headers
Complete Article Headers
From: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
Message-ID: <9601250655.8394@mulga.cs.mu.OZ.AU>
X-Original-Date: Thu, 25 Jan 1996 17:55:54 +1100
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
Date: 25 Jan 96 07:40:17 GMT
Approved: fjh@cs.mu.oz.au
Newsgroups: comp.std.c++
Subject: Re: Why no allocator-specific delete?
Organization: Computer Science, University of Melbourne, Australia
References: <4dvid8$460@news.bridge.net> <4e0u1s$5fv@engnews1.Eng.Sun.COM>
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMQcz8eEDnX0m9pzZAQHcagF/TDs98kUv8id6nGgFFktQR7LHQ0vfYBxi
 WVQ1O+jdzCzDFfbKYab5KIg6zxAjQV0f
 =dE18