Skip to main content
The 2026 Annual Developer Survey is live— take the Survey today!

Timeline for answer to reinterpret_cast and cross casting by Werner Henze

Current License: CC BY-SA 3.0

Post Revisions

7 events
when toggle format what by license comment
Apr 16, 2013 at 12:09 comment added metalhead @CharlesBailey: Fair enough, but for once VS's undefined behavior is as desired and it does work. I just tried it out, but you are right that it can't be counted upon.
Apr 16, 2013 at 12:08 history edited Werner Henze CC BY-SA 3.0
added explanation that the pointers to each struct/class are not equal
Apr 16, 2013 at 12:03 comment added Lara Bailey @metalhead: But the reinterpret_cast is wrong and won't work (unless you get very lucky with your undefined behavior), so that only leaves the two possibilities in this answer.
Apr 16, 2013 at 12:03 comment added metalhead @CharlesBailey: The OP said nothing about static_cast and it is not needed for dynamic_cast or reinterpret_cast
Apr 16, 2013 at 12:01 comment added Lara Bailey @metalhead: You need to go via C12* if you are using a static_cast.
Apr 16, 2013 at 12:00 comment added metalhead I don't know what compiler you are using, but you don't need the intermediate step in VS2010.
Apr 16, 2013 at 11:59 history answered Werner Henze CC BY-SA 3.0