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 Davislor

Current License: CC BY-SA 4.0

Post Revisions

7 events
when toggle format what by license comment
Jul 17, 2018 at 13:23 history edited Davislor CC BY-SA 4.0
added 32 characters in body
Jul 17, 2018 at 13:10 comment added curiousguy Yes indeed a reinterpret_cast to a reference type does a reinterpretation. That a reference type was used wasn't clear from your previous comment.
Jul 16, 2018 at 18:40 comment added Davislor @curiousguy [expr.reinterpret.cast.11], although that says it needs to be cast to a reference.
Jul 16, 2018 at 17:32 comment added Davislor @curiousguy Certain integer casts do. A cast between signed and unsigned integral types does, and so does a cast from void* to uintptr_t. On the other hand, a reinterpret_cast from double to uint64_t is a type-pun, while a C-style cast has the semantics of static_cast, which represents the value as closely as possible.
Jul 16, 2018 at 16:23 comment added Davislor @curiousguy That’s when you reinterpret the bits of some object’s binary representation as if it were a different type. For example, treating the bits of a 64-bit double as a uint64_t so you can twiddle them. Especially when the method is declaring a union, writing to a member of one type, and reading out a member of a different type (which is legal in C, but, as you know, undefined behavior in C++).
Jul 16, 2018 at 15:07 comment added curiousguy What is a "type-pun"?
Jul 9, 2018 at 18:57 history answered Davislor CC BY-SA 4.0