Issue 2859: Definition of reachable in [ptr.launder] misses pointer arithmetic from pointer-interconvertible object (original) (raw)
This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++20 status.
2859. Definition of reachable in [ptr.launder] misses pointer arithmetic from pointer-interconvertible object
Section: 17.6.5 [ptr.launder] Status: C++20 Submitter: Hubert Tong Opened: 2017-01-31 Last modified: 2021-02-25
Priority: 2
View all other issues in [ptr.launder].
View all issues with C++20 status.
Discussion:
Given:
struct A { int x, y; }; A a[100];
The bytes which compose a[3]
can be reached from &a[2].x
:reinterpret_cast<A *>(&a[2].x) + 1
points to a[3]
, however, the definition of "reachable" in [ptr.launder] does not encompass this case.
[2017-03-04, Kona]
Set priority to 2. Assign this (and 2860(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 to N4618.
- Modify 17.6.5 [ptr.launder] as indicated:
template constexpr T* launder(T* p) noexcept;
[…]
-3- Remarks: An invocation of this function may be used in a core constant expression whenever the value of its argument may be used in a core constant expression. A byte of storage
_b_
is reachable through a pointer value that points to an object_Y_
if there is an object_Z_
, pointer-interconvertible with_Y_
, such that_b_
itis within the storage occupied by_Z~~Y~~_
,an object that is pointer-interconvertible withor the immediately-enclosing array object if_Y_
,_Z~~Y~~_
is an array element. The program is ill-formed ifT
is a function type or (possibly _cv_-qualified)void
.