This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix C++ strict-aliasing issues with memcpy folding


Hi,

On Wed, 3 Feb 2010, Gabriel Dos Reis wrote:

> > Now, answer this question: "how do I release the storage allocated at
> > (1)?",
> 
>    operator delete(p);

Okay.  It's awkward, but correct.  I just hope that every user of 
libraries that internally use placement new know that for some returned 
object pointers they must not delete them, but use 'operator delete' to 
just release storage.

Another question: The program from last mail again:

struct X { int count; char mem[8]; } *p;
p = new X;
...                                  // e.g. init all members of *p
float *f = new (&p->mem[0]) float;
*f = 1.0;

Is it allowed to access p->count after this assignment to float?  After 
all it's part of *p, which doesn't exist anymore, hence the access should 
be invalid, right?


Ciao,
Michael.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]