- Title
- Null pointer preservation in void* conversions
- Status
- cd1
- Section
- 7.3.12 [conv.ptr]
- Submitter
- comp.std.c++
Created on 2005-05-19.00:00:00 last changed 217 months ago
Messages
Date: 2006-04-15.00:00:00
[Voted into WP at April, 2006 meeting.]
Date: 2005-10-15.00:00:00
Proposed resolution (October, 2005): Add the indicated words to 7.3.12 [conv.ptr] paragraph 2:
Add the indicated words to 7.6.1.9 [expr.static.cast] paragraph 11:
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.8.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.
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...
Date: 2026-07-25.21:52:10
The C standard says in 6.3.2.3, paragraph 4: C++ appears to be incompatible with the first sentence in only two
areas: C++ (7.3.12 [conv.ptr] paragraph 2) says nothing about the
value of 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:
Add the following sentence to 7.6.1.9 [expr.static.cast] paragraph 10:
Conversion of a null pointer to another pointer type yields a null
pointer of that type. Any two null pointers shall compare equal.
A *a = 0;
void *v = a;
void *v = 0;
A *b = (A*)v; // aka static_cast<A*>(v)
The null pointer value is converted to the null pointer value of the
destination type.
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 | |