On 08/03/2011 02:26 PM, Jakub Jelinek wrote:
As for the properties which the middle-end would like to assume or not
from the operator new/operator new[]:
1) for alloc_size it is whether the returned pointer has exactly the
requested bytes defined, i.e. can't return a buffer where only fewer bytes
are valid and it is invalid to access bytes beyond those that were requested

"If it is successful, it shall return the address of the start of a block of storage whose length in bytes shall be at least as large as
the requested size."

I suppose this leaves room for a user operator new to allocate some extra space at the end and other code to take advantage of that, though I would be surprised if anyone actually did that.

2) aliasing - is the returned buffer guaranteed not to alias any other
object the program may validly access?

Not currently.

3) side-effects - currently for malloc we assume it has no visible
side-effects other than allocating the memory (i.e. malloc internals are
treated as black box), I guess for user supplied operator new/operator
new[] we shouldn't assume it doesn't have other side-effects (thus e.g. we
shouldn't optimize it away, etc.)

We have no guarantees about what side-effects a user-supplied operator new might have.

Jason

Reply via email to