Skip to content

CWG2719 [intro.object] p3 The provided storage should satisfy the alignment requirement of the created object #294

Closed
cplusplus/draft
#6328
@xmh0511

Description

@xmh0511

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

[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 storage for the new object fits entirely within e, and
  • there is no array object that satisfies these constraints nested within e.

No bullet in the list explicitly mentions the alignment requirement of the object being created. [basic.life] p1 says

The lifetime of an object of type T begins when:

  • storage with the proper alignment and size for type T is obtained, and

The array with the element of type unsigned char or std​::​byte has the weakest alignment requirement per [basic.align] p6 and [expr.alignof] p3. That is, the storage provided by the array is not necessary to satisfy the alignment requirement of the object being created.

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