This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


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

Re: AIX I/O failures


Mark Mitchell <mark@codesourcery.com> writes:

| >>>>> "Gabriel" == Gabriel Dos Reis <gdr@codesourcery.com> writes:
| 
|     Gabriel> Placement new is a different matter -- it keeps the type
|     Gabriel> as is.
| 
| Not in general.  Things like:
| 
|   char* c = new char [sizeof(S)] ;
|   new (c) S;
| 
| are specifically endorsed.

No.  That is defined only if S has the same alignment as char -- that
is what you're trying to get right with the extension __aligned__.  

Furthermore, after the new-placement, 'c' doesn't magically get type
S.  Placement new is for when you have the storage and want to
construct something there.


| The usage I gave was actually one of the earlier motivations for
| placement new, IIRC.  The idea being that you sometimes wanted to
| control *when* an object was constructed,

*Where* an object should be created.

| ...  but specifically *not* have
| to pay for an extra indirection.

That doesn't match the discussion found in the de-facto pre-standard
reference: ARM.  I've just checked :-)

The motivation of placement-new is to control where objects should be
placed and specifically avoid type-games.

-- Gaby
CodeSourcery, LLC                       http://www.codesourcery.com

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