Boost logo

Boost :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2003-10-09 22:44:52


On Thursday 09 October 2003 10:46 pm, E. Gladyshev wrote:
> --- Douglas Gregor <gregod_at_[hidden]> wrote:
> > At the line
> >
> > T* obj = new (data_) T;
> >
> > you've ended the lifetime of the object that used to be in data_.
>
> So that is the definition of "reusing storage" in the standard.
> How about T* obj = new( (char*)data_+3 ) T ? Is it still ending
> the object's lifetime? There is not such definition in the standard.

That's an example, not a definition. Reusing storage means that part of the
storage associated with an object is used to construct an object of a
different type.

> The standard is lacking a consistent definition of "storage"
> and storage usage concepts.

Then find the inconsistency! If you're looking for a single clause that spells
out exactly what you want to see, you won't find it. Read the relevant bits
on object sizes, object lifetimes, alignment, padding, and object aliasing
and deduce what you need to make or break your case. If perchance you find
that logical reasoning brings you two conclusions that are at odds, report
it.

> If the "reusing storage" concept is undefined, the object liftime is
> undefined.

It's hard to stay this without being incendiary, but just because you were not
able to deduce the concept of "reusing storage" from the standard text does
not mean that it is undefined.

This thread needs to end. It has wasted too much time and too much bandwidth
so far, and has produced nothing. The method you have proposed does not work,
as has been pointed out several times. If you would like to try another
approach, please feel free to. However, do not expect us to hold you hand to
lead you to the conclusion we have already reached long ago, that any
approach based on copying the bits of an object around leads to undefined
behavior.

        Doug


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk