Created on 2023-10-20.00:00:00 last changed 1 month ago
Proposed resolution (approved by CWG 2024-03-18):
Change in 7.6.1.9 [expr.static.cast] paragraph 14 and add bullets as follows:
A prvalue of type “pointer to cv1 void” can be converted to a prvalue of type “pointer to cv2 T”, where T is an object type and cv2 is the same cv-qualification as, or greater cv-qualification than, cv1. If the original pointer value represents the address A of a byte in memory , T is complete, and A does not satisfy the alignment requirement of T, then the resulting pointer value is unspecified. Otherwise, ...
CWG 2023-03-18
CWG decided to reverse direction here and to constrain implementations, not programs.
CWG 2023-12-15
The resulting pointer value should be unspecified if T is incomplete.
Consider:
struct X; // declared, but not defined
int i;
X* p = static_cast<X*>(static_cast<void*>(&i));
Is the value of p unspecified per 7.6.1.9 [expr.static.cast] paragraph 14?
A prvalue of type “pointer to cv1 void” can be converted to a prvalue of type “pointer to cv2 T”, where T is an object type and cv2 is the same cv-qualification as, or greater cv-qualification than, cv1. If the original pointer value represents the address A of a byte in memory and A does not satisfy the alignment requirement of T, then the resulting pointer value is unspecified. Otherwise, ...
Is that a case where implementations have to possibly pessimize a use of an undefined class, because a later definition can have the worst possible properties? Such a situation can also occur for pointer-to-members of undefined classes.
History | |||
---|---|---|---|
Date | User | Action | Args |
2024-03-20 14:10:31 | admin | set | messages: + msg7649 |
2024-03-20 14:10:31 | admin | set | messages: + msg7648 |
2023-12-16 00:18:01 | admin | set | messages: + msg7556 |
2023-12-16 00:18:01 | admin | set | status: open -> review |
2023-10-20 00:00:00 | admin | create |