On 9/9/07, Richard Guenther <[EMAIL PROTECTED]> wrote: > > Which brings back the fact that you cannot implement malloc in C > (you certainly remember the discussions about C++ placement new > handling wrt aliasing). To re-use the machinery we invented there > we would need to place a CHANGE_DYNAMIC_TYPE_EXPR for > the pointer assignment resulting from inlining a function with > attribute malloc set. As you say, unless we are inlining such functions > we are safe in practice.
Actually this looks nice in general. We could implement placement new in C this way: extern inline T * __attribute__((malloc)) placement_new (void *p) { return p; } if we can somehow encode the target type here. Note that only type-based aliasing is a problem with this discussion - PTA will be obviously fine if new is inlined as it will see that both pointers are related and we loose the 'malloc' attribution on the target pointer during inlining. Richard.