On Aug 22, 2013, at 9:45 AM, Gabriel Dos Reis <g...@integrable-solutions.net> 
wrote:
>> I.e. can I have something like
>> 
>> int a;
>> test()
>> {
>>  int *b=new (int);
>> }
>> 
>> with custom implementation of new that returns &a?
> 
> If the user-supplied operator new returns &a, then it must
> also ensure that 'a' is not used anywhere else -- e.g. I you can't
> do lvalue-to-value conversion on 'a' to see what is written there.

This is wrong, in the c++97 standard there is no such limitation or restriction.

> Because its storage has been reused.  That is, aliasing is framed
> in terms of object lifetime and uniqueness of ownership.

Nope, this is wrong.  Example:

int i, j;

main() {
        i = 1;
        j = i;


        i = 2;
        char *cpi = (char*)&i;
        char *cpj = (char*)&j;
        for (k= 0; k < sizeof (int); ++k)
                cpj[k] = cpi[k];
}

This is well defined.  i and j exist, as do the character objects that are 
pointed to by cpi and cpj.  One can use them and interleave them, they can 
alias, and the character objects are not unique from i and j.

Reply via email to