array new-expressions: proposal

Daveed Vandevoorde daveed at edg.com
Sat Jan 22 00:23:54 UTC 2000


Christophe de Dinechin wrote:
[...]
> I sent a message to the -libraries mailing list. Although I agree with the
> intent, there is also the question of how you expect people to delete[] it.

If the allocation was on the stack, they shouldn't delete it.
If they are "overconstructing" as in:

	p = new T[100];
	// ...
	(void)new(p+25) T[50]; // End lifetime of middle 50 objects and
	                       // replace by 50 new ones.

they should be able to just use a delete[] expression for the desired effect.

It's a bit unfortunate that all the multi-argument allocation functions are
called "placement new".  Only this one and the corresponding object-new
really qualify.  Note also that these are the ones a user is not allowed to
override, thereby further suggesting that they are "intrinsic" and more 
about "placement" than "allocation".

I agree with John Wilkinson that the array case is an order of magnitude 
less interesting than the object case.  However, the user is king and
you'll have a hard time explaining to your customer that this doesn't
work when "it always worked that way" and "that other platform has no
trouble with it and they also store a count at negative offsets in the
other cases".  It might be that noone actually does this kind of thing,
but I'm not comfortable betting on it---there is some really weird C++
middleware source code out there.

	Daveed




More information about the cxx-abi-dev mailing list