Re: Duplicate const_cast vs reinterpret_cast

Based on the reply to this Meta Question how to appeal a closed question? I am appealing for a reopen

I had asked a Question in SO viz Reinterpret Cast and Const Cast. I also linked to an iconic SO Question When should static_cast, dynamic_cast and reinterpret_cast be used? to explain my question better. I took adequate effort to ensure that the linked question was not sufficient enough to solve my problem.

To my surprise, this Question got closed as the exact duplicate of the linked question.

I could have opened a new question and shared a bounty but I would like to ensure that the newly opened question doesn't get closed in the similar way.

In case, closevoters firmly conclude that its an exact duplicate, I would also like to get a reasonable explanation

  • 2
    Your links seem a little mixed up. – Michael Petrotta Jan 12 '13 at 5:12
  • @MichaelPetrotta: Sorry for this Issue. The links are now fixed – Abhijit Jan 12 '13 at 6:12

Your SO question is probably confusing people, because the part you quote is the answer to your question:

Largely, the only guarantee you get with reinterpret_cast is that if you cast the result back to the original type, you will get the exact same value.

All reinterpret_cast does is give a sequence of bits another interpretation - same bits with a new type. Whether that works or not, depends on just about everything in a specific implementation. Using the reinterpret_cast you tell the compiler that is does work, because you just know more than it does. Basta!

Of course, if you convert the same bit sequence back to its original type, the content will still be the same. That is all the standard guarantees, and that is what the original answer states.

So, in my opinion the orignal question and answers duplicate your question by explaining all the different casts, not just the two you ask about. There really is nothing more to add.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .