Skip to content

[basic.life] p1.5 and [intro.object] p3 have a circular dependency on each other #247

@xmh0511

Description

@xmh0511

Full name of submitter (unless configured in github; will be published with the issue): Jim X

[basic.life] p1.5 says:

The lifetime of an object o of type T ends when:

  • [...]
  • the storage which the object occupies is released, or is reused by an object that is not nested within o ([intro.object]).

The wording implies: if an object o2 reuses the storage occupied by o1 but o2 is nested within o1, o2 does not end the lifetime of o1.

[intro.object] p3 says

If a complete object is created ([expr.new]) in storage associated with another object e of type “array of N unsigned char” or of type “array of N std​::​byte” ([cstddef.syn]), that array provides storage for the created object if:

  • the lifetime of e has begun and not ended, and

The first requirement says the lifetime of e is not ended. In other words, whether o2 is nested within o1 or not is first determined by whether o2 reuses the storage of o1 will end the lifetime of o1, and the latter is, in turn, determined by whether o2 is nested within o1 per [basic.life] p1.5.

Suggested resolution

that array provides storage for the created object if:

  • the lifetime of e has begun and not ended other than the created object reused the storage would end the lifetime of e

The added wording intends to mean: we uniformly assume that the reuse of the storage can end the lifetime, and we say the lifetime e shouldn't be ended other than the former case, which can break the circular dependency. If other requirements all be satisfied, then we say e provides storage for the created object, hence the created object does not actually end the lifetime of the object providing the storage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions