Created on 2003-10-30.00:00:00 last changed 33 months ago
[Voted into WP at April 2005 meeting.]
Proposed resolution:
Change 7.6.1.9 [expr.static.cast] paragraph 10 as indicated:
A value of type pointer to object converted to "pointer to cv void" and back to the original pointer type, possibly with different cv-qualification, will have its original value. [Example:T* p1 = new T; const T* p2 = static_cast<const T*>(static_cast<void *>(p1)); bool b = p1 == p2; // b will have the value true.---end example]
Rationale: The wording "possibly with different cv-qualification" was chosen over the suggested wording to allow for changes in cv-qualification at different levels in a multi-level pointer, rather than only at the object type level.
Paragraph 7.6.1.9 [expr.static.cast] paragraph 10 says that:
A value of type pointer to object converted to "pointer to cv void" and back to the original pointer type will have its original value.
That guarantee should be stronger. In particular, given:
T* p1 = new T; const T* p2 = static_cast<const T*>(static_cast<void *>(p1)); if (p1 != p2) abort ();there should be no call to "abort". The last sentence of Paragraph 7.6.1.9 [expr.static.cast] paragraph 10 should be changed to read:
A value of type pointer to object converted to "pointer to cv void" and back to the original pointer type (or a variant of the original pointer type that differs only in the cv-qualifiers applied to the object type) will have its original value. [Example:---end example.]T* p1 = new T; const T* p2 = static_cast<const T*>(static_cast<void *>(p1)); bool b = p1 == p2; // b will have the value true.
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-02-18 07:47:23 | admin | set | messages: + msg6691 |
2008-10-05 00:00:00 | admin | set | status: wp -> cd1 |
2005-10-22 00:00:00 | admin | set | status: dr -> wp |
2005-05-01 00:00:00 | admin | set | messages: + msg1187 |
2005-05-01 00:00:00 | admin | set | status: ready -> dr |
2004-11-07 00:00:00 | admin | set | status: review -> ready |
2004-04-09 00:00:00 | admin | set | status: open -> review |
2003-10-30 00:00:00 | admin | create |