C++ Logo

sg12

Advanced search

Re: [ub] Type punning to avoid copying

From: Gabriel Dos Reis <gdr_at_[hidden]>
Date: Mon, 09 Sep 2013 12:44:18 -0500
Jeffrey Yasskin <jyasskin_at_[hidden]> writes:

| On Sun, Sep 8, 2013 at 9:48 PM, Gabriel Dos Reis <gdr_at_[hidden]> wrote:
| > | In fact, it is not at clear that either programmers or compilers want
| > | a notion of 'object resuscitation'.
| > |
| > |
| > | I don't know what you mean by 'resuscitation' here. Can you elaborate?
| >
| > Resuscitation here refer to the idea that
| >
| > "there exists a set of times when objects' lifetimes begin and end, and
| > that set gives the program defined behavior, then the program has
| > defined behavior"
| >
| > If we don't have a uniquely defined point in time where the lifetime of
| > an object starts, that means that either it never started or it started
| > and ended multitple times.
|
| I think you've misread Richard here. He didn't say "a set of times

I am not sure but only Richard knows whether he meant to talk about a
specific object's lifetime or the lifetimes of a collection of objects.

If the latter, that is a very surprising way to tackle the issue since
it does not appear to shed more light than the conversation about the
lifetime of a given object.

| when an object's (singular, possessive) lifetimes begin and end"; he
| said "a set of times when objects' (plural, possessive) lifetimes
| begin and end". I read that as a mapping of an object to the point in
| time when its lifetime begins and the point in time when its lifetime
| ends.

Here is the original paragraph:

# More generally, my view of how the lifetime rules in [basic.life]p1 are
# intended to work is:
# * If there exists a set of times when objects' lifetimes begin and end, and
# that set gives the program defined behavior, then the program has defined
# behavior
# * Otherwise, the program has undefined behavior
#
# (In effect, the programmer chooses when lifetimes begin and end, and does not
# need to write this intent in the source code.) Different choices of lifetime
# beginning/end can only change whether the program has defined behavior, and
# cannot imbue it with two different defined behaviors, so this approach seems to
# be coherent, and (I think) captures what people expect.

-- Gaby

Received on 2013-09-09 19:44:35