Boost logo

Boost :

From: E. Gladyshev (egladysh_at_[hidden])
Date: 2003-10-10 00:53:22


--- Douglas Gregor <gregod_at_[hidden]> wrote:
> On Friday 10 October 2003 12:02 am, E. Gladyshev wrote:
> > char *p = new( (void*)&m.x );
> >
> > I am using the part of already constructed object 'm' to construct
> > another object so is 'm' lifetime is over?
>
> Apparently you did not read the clause David A. cited. Part of it says:
> 12.6.2 describes the lifetime of base and member subobjects
>
> Did you read 12.6.2?

Of course I read the standard and I reread 12.6.2
it is not relevant to reusing storage.
What is relevant is 3.7.4

"The storage duration of member subobjects, base class subobjects and
  array elements is that of their complete object "

Now let go back to my example.

According 3.8.4 (IF WE ASSUME THAT 'new(obj)' is "reusing storage") when I call
char *p = new( (void*)&m.x ) char;

I end lifetime of m.x, so I end the storage duration of a member subobject.

According to 3.7.4
The storage duration of m.x is the same as the its complete object.

Do you see what I am talking about? "reusing storage" has to be
consistently defined to fit into the whole picture.

> I have: http://lists.boost.org/MailArchives/boost/msg53635.php

I just proved you wrong.

> Summary: you ended the lifetime of an object, then tried to resurrect it by
> copying the bits back. It doesn't even take *any* deduction to see that the
> code invokes undefined behavior, because the standard explicitly states what
> happens, and we've quoted the relevant clause.

The standard used undefined concepts when it states what happens.

[...]
>
> Wait, so we're supposed to rewrite an international standard first, and then
> come back to this discussion? Even if this were even remotely feasible (it
> isn't), this is the wrong forum for such things. We develop C++ libraries; we
> do not write standards.

No, you are not supposed to rewrite anything. It is not the point of
the discussion. The point is to reach a trully correct conclusion.
How to deal with it is another story.

> At Boost we try to keep an open mind, we hope to learn from each other, and we
> don't mind teaching from time to time. We do enjoy a fresh perspective on an
> old problem, and some problems that were considered unworkable have indeed
> been solved. But they have not been solved by ignoring the old arguments, the
> ones that prove ways in which the problem can't be solved. You have
> categorically refused to do your share

What do you mean exactly by "refused to do your share"?

Eugene

__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping.yahoo.com


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