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

Timeline for answer to Reinterpret_cast vs. C-style cast by Konstantin Oznobihin

Current License: CC BY-SA 4.0

Post Revisions

8 events
when toggle format what by license comment
Jul 9, 2018 at 17:00 history edited Donald Duck is with Ukraine CC BY-SA 4.0
removed unnecessary linebreaks at the beginning and end of the code blocks and made markdown code more readable
Oct 20, 2011 at 9:22 comment added Loki Astari @edA-qamort-ora-y: Yes it is 5.2.10/4 "A pointer can be explicitly converted to any integral type large enough to hold it" 5.2.10/7 "pointer to T1” is converted to the type “pointer to cv T2”, the result is static_cast<cv T2*>(static_cast<cv void*>(v))" Thus reinterpret cast works for casting too and from void*. And more importantly in my eyes. reinterpret_cast<> sticks out in the code more than static_cast<> and thus has a higher degree of scrutiny.
Oct 20, 2011 at 9:05 comment added edA-qa mort-ora-y For void* (on object types) round-trip using static_cast will work. The result is the same in this case, but might prevent you from accidentally casting to the wrong type.
Oct 20, 2011 at 9:04 comment added Konstantin Oznobihin @LokiAstari: when A is an object type :) Anyhow, if one needs a full and precise picture it's better to take a look at the standard.
Oct 20, 2011 at 8:41 comment added Loki Astari @edA-qa mort-ora-y: Assuming the integer is large enough to hold the pointer. The most important one (IMO) is round trip from A* -> void* -> A* yields the original.
Oct 20, 2011 at 7:43 comment added edA-qa mort-ora-y The standard provides several guarantees and requirements for reinterpret_cast. The most important is that round-trip conversion, pointer to integer to pointer yields the original pointer. Furthermore, C++ solidifies the expected behaviour of casting with standard layout types.
Oct 20, 2011 at 6:46 history edited Konstantin Oznobihin CC BY-SA 3.0
added 453 characters in body
Oct 20, 2011 at 6:34 history answered Konstantin Oznobihin CC BY-SA 3.0