Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6733179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:44:17+00:00 2026-05-26T10:44:17+00:00

I want to know if there are specific, standards-based differences between two different types

  • 0

I want to know if there are specific, standards-based differences between two different types of casts of very particular types. In particular, given: type T and a variable T * object is:

intptr_t opaque = reinterpret_cast<intptr_t>( object );
T * result = reinterpret_cast<T*>( opaque );

equivalent to:

void * opaque = static_cast<void*>( object );
T * result = static_cast<T*>( opaque );

I only care about the result, is it guaranteed to be the same value, equivalent to the original object for any type T? I don’t care what bit pattern the intermediate opaque has, as I believe the standard technically allows them to be different in each case (though no sane compiler would have different results).

Note, I’m not interested in the generic case of static_cast vs. reinterpret_cast, that I understand well. What I’m interested is in the above very specific case — resulting from the standard assigning special logic to static_cast and void* that make it behave similar to a reinterpret_cast. (There are several related questions on StackOverflow, but they are more generic, and my scenario I believe is highly specific)

Style and preference aside, is there any technical reason why one form should be used over the over? Or is it guaranteed, for all T to produce the same final result variable?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:44:18+00:00Added an answer on May 26, 2026 at 10:44 am

    Yes, both are guaranteed to restore the original pointer value.

    The first is specified by C++11 5.2.10/5:

    A pointer converted
    to an integer of sufficient size (if any such exists on the implementation) and back to the same pointer type
    will have its original value;

    The second is specified by C++11 5.2.9/13:

    A value of type pointer to object
    converted to “pointer to cv void” and back, possibly with different cv-qualification, shall have its original
    value.

    There is a technical reason to prefer the second version over the first one: intptr_t is optional, but every implementation has void*.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to know there a limitation in size for an iphone to display
I know there is this post , but I still want to know more
Just want to know if there other optional wrapper framework available that generate client
I want to know if there is any way by which I can paste
I want to know if there is any free tool to test the performance
I want to know if there are any existing benchmarks and sizing information for
I want to know if there is an equivalent cron in Windows and how
I want to know if there is a better way (than what I'm currently
I just want to know if there is a program that can convert an
I am starting using logback and I want to know if there are better

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.