Movatterモバイル変換


[0]ホーム

URL:



This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofC++20 status.

2859. Definition ofreachable in [ptr.launder] misses pointer arithmetic from pointer-interconvertible object

Section: 17.6.5[ptr.launder]Status:C++20Submitter: Hubert TongOpened: 2017-01-31Last modified: 2021-02-25

Priority:2

View all otherissues in [ptr.launder].

View all issues withC++20 status.

Discussion:

Given:

struct A { int x, y; };A a[100];

The bytes which composea[3] can be reached from&a[2].x:reinterpret_cast<A *>(&a[2].x) + 1 points toa[3],however, the definition of "reachable" in [ptr.launder] does not encompass this case.

[2017-03-04, Kona]

Set priority to 2. Assign this (and2860(i)) to Core.

[2017-08-14, CWG telecon note]

CWG is fine with the proposed resolution.

[2020-02 Status to Immediate on Thursday night in Prague.]

Proposed resolution:

This wording is relative toN4618.

  1. Modify 17.6.5[ptr.launder] as indicated:

    template <class T> constexpr T* launder(T* p) noexcept;

    […]

    -3-Remarks: An invocation of this function may be used in a core constant expression whenever the valueof its argument may be used in a core constant expression. A byte of storageb is reachable through a pointer value that points to an objectY ifthere is an objectZ, pointer-interconvertible withY, such thatbit is within the storage occupied byZY,an object that is pointer-interconvertible withY, or the immediately-enclosing array object ifZY is an array element. The program is ill-formed ifT is a function type or (possiblycv-qualified)void.


[8]ページ先頭

©2009-2026 Movatter.jp