On Fri, Jun 15, 2007 at 08:00:24PM -0700, michael.a wrote:
> I've actually never seen "placement new" before I think. Its a useful way to
> "reconstruct" heaped memory, but not useful in anyway in the situation I
> described (which is really broader than any single fix)

I disagree; placement new is much more flexible than that, and can be used
to construct an object inside a static, automatic, or global object.  It
can be used to implement generalized unions, or as a way to control
placement of memory-mapped objects.  Furthermore, you've almost certainly
used it without knowing it, since the STL uses it a lot.  But if you really
want your existing code to work, you'd need to extend the compiler.  If
your code is modular, and doesn't expose all over the place the particular
use of unions you described, it wouldn't be hard to switch to a
placement-new implementation.  Otherwise it could be a hopeless task.

> PS: I did receive another response by mail, but I'm not seeing it in the
> thread. Perhaps it was a private response only somehow. In any case it
> suggested that nonstandard extensions to GCC cut against its philosophy. I
> do believe GCC supports the standard "for loop scope" extension (which seems
> so practical, that many compilers default to it) ...likewise, permitting
> ctored structs in a union seems equally, if not more so practical, and the
> omission just as absurd. It would seem like a natural nonstandard inclusion,
> at least until the c++ specs are amended to include it. 

I wouldn't object if someone implemented a clean extension.  The problem
with extensions, though, is documenting how all the corner cases work,
and making sure that they all get tested.  This is somewhat easier when
you're cloning someone else's extension, because the other implementation
can be used for comparison.

Reply via email to