Created on 2005-05-19.00:00:00 last changed 196 months ago
[Voted into WP at April, 2006 meeting.]
Proposed resolution (October, 2005):
Add the indicated words to 7.3.12 [conv.ptr] paragraph 2:
An rvalue of type “pointer to cv T,” where T is an object type, can be converted to an rvalue of type “pointer to cv void”. The result of converting a “pointer to cv T” to a “pointer to cv void” points to the start of the storage location where the object of type T resides, as if the object is a most derived object (6.7.2 [intro.object]) of type T (that is, not a base class subobject). The null pointer value is converted to the null pointer value of the destination type.
Add the indicated words to 7.6.1.9 [expr.static.cast] paragraph 11:
An rvalue of type “pointer to cv1 void” can be converted to an rvalue 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. The null pointer value is converted to the null pointer value of the destination type. A value of type pointer to object converted to “pointer to cv void” and back, possibly with different cv-qualification, shall have its original value...
The C standard says in 6.3.2.3, paragraph 4:
Conversion of a null pointer to another pointer type yields a null pointer of that type. Any two null pointers shall compare equal.
C++ appears to be incompatible with the first sentence in only two areas:
A *a = 0; void *v = a;
C++ (7.3.12 [conv.ptr] paragraph 2) says nothing about the value of v.
void *v = 0; A *b = (A*)v; // aka static_cast<A*>(v)
C++ (7.6.1.9 [expr.static.cast] paragraph 10) says nothing about the value of b.
Suggested changes:
Add the following sentence to 7.3.12 [conv.ptr] paragraph 2:
The null pointer value is converted to the null pointer value of the destination type.
Add the following sentence to 7.6.1.9 [expr.static.cast] paragraph 10:
The null pointer value (7.3.12 [conv.ptr]) is converted to the null pointer value of the destination type.
History | |||
---|---|---|---|
Date | User | Action | Args |
2008-10-05 00:00:00 | admin | set | status: wp -> cd1 |
2006-11-05 00:00:00 | admin | set | status: dr -> wp |
2006-04-22 00:00:00 | admin | set | messages: + msg1360 |
2006-04-22 00:00:00 | admin | set | status: ready -> dr |
2005-10-22 00:00:00 | admin | set | messages: + msg1217 |
2005-10-22 00:00:00 | admin | set | status: open -> ready |
2005-05-19 00:00:00 | admin | create |