This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 116a. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.
2024-12-19
[Accepted at the July, 2022 meeting.]
Consider:
struct S { int a[5]; } s; int (*p)[] = reinterpret_cast<int(*)[]>(&s); int n = (*p)[0];
This ought to have defined behavior: a pointer to s and a pointer to s.a are pointer-interconvertible, so you should be able to navigate between them this way. But the cast as shown does not work, because the type of the pointer-interconvertible object is int[5], not int[].
Proposed resolution (approved by CWG 2022-07-01):
Change in 7.6.1.9 [expr.static.cast] paragraph 13 as follows:
... Otherwise, if the original pointer value points to an object a, and there is an object b of type similar to T(ignoring cv-qualification)that is pointer-interconvertible (6.8.4 [basic.compound]) with a, the result is a pointer to b. Otherwise, the pointer value is unchanged by the conversion.