array new-expressions: proposal

Matt Austern austern at isolde.engr.sgi.com
Mon Jan 24 18:29:44 UTC 2000


On Jan 23,  1:40am, Jason Merrill wrote:

> Matt:  Why not just say
>
>   padding = max (sizeof (size_t), alignof (T))
>
> ?  I don't see any reason to mention long double by name, and I don't
> see much of a reason to treat char specially, either.  Are there any
> alignment constraints on 'new char' in the standard?

There are specific constraints on char and unsigned char, yes.
(But not, interestingly enough, on signed char or on any other
type of size 1.)

5.3.4/10: "For arrays of char and unsigned char, the difference between
the result of the new-expression and the address returned by the
allocation function shall be an integral multiple of the most stringent
alignment requirement of the object type whose size is no greater than
the size of the array being created."

We could just put in 16-byte padding for all types, but I think that's
a waste.  There's no reason to do it.  It's just as easy to use 8-
byte padding in general, and 16 only when we have to.

			--Matt





More information about the cxx-abi-dev mailing list