[ub] Type punning to avoid copying

Gabriel Dos Reis gdr at axiomatics.org
Mon Sep 9 19:44:18 CEST 2013


Jeffrey Yasskin <jyasskin at google.com> writes:

| On Sun, Sep 8, 2013 at 9:48 PM, Gabriel Dos Reis <gdr at axiomatics.org> 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


More information about the ub mailing list