Created on 2022-06-28.00:00:00 last changed 27 months ago
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.
[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[].
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-08-19 07:54:33 | admin | set | status: ready -> cd6 |
2022-07-01 20:56:37 | admin | set | status: open -> ready |
2022-06-30 16:25:58 | admin | set | messages: + msg6874 |
2022-06-28 00:00:00 | admin | create |