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 8206817
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:48:07+00:00 2026-06-07T08:48:07+00:00

I have a const pointer to a pointer to a Fred and I don’t

  • 0

I have a const pointer to a pointer to a Fred and I don’t understand why a static_cast isn’t sufficient.

typedef struct {
    int n;
} Fred;

Fred *pFred;
Fred **const ppFred = &pFred;
void **const ppVoid = static_cast<void ** const>(ppFred);

Please could someone explain why a reinterpret_cast is needed to convert a pointer to Fred*to a pointer to void* but static_cast is fine to convert pointer to Fred to a pointer to void.

  • 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-06-07T08:48:08+00:00Added an answer on June 7, 2026 at 8:48 am

    There’s no requirement that a Fred* and a void* have the same size
    and representation. (I’ve worked on machines where they didn’t,
    although that was before my C++ days.) When you convert Fred* to
    void*, you get a new pointer, with a possibly different size and
    representation, but there is no information about the size and
    representation of the object the void* points to. You know that it is
    unknown, and the only way to use this void* is to cast it back to a
    Fred* (modulo things like cv-qualifiers). When you convert Fred**
    to void**, you’re converting from a pointer to a concrete type (a
    pointer to a Fred*) to a pointer to another concrete type (a pointer
    to a void*). And since there’s no guarantee that these two concrete
    types have the same size and representation, the conversion requires a
    reinterpret_cast. void is a special, non-concrete type, so you can
    static_cast a pointer to any type to and from a pointer to void.
    void* is just another concrete pointer type, so casting to and from
    pointers to it follows the usual rules (and requires a
    reinterpret_cast).

    In many ways, the situation is very much like int and double, where
    void* plays the role of int (say), and Fred* the role of double.
    There’s no problem static_casting between int and double, but
    casts between int* and double* require reinterpret_cast.

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

Sidebar

Related Questions

I have the following code: template <class T> struct pointer { operator pointer<const T>()
I have the following C++ code: typedef int* IntPtr; const int* cip = new
I have a struct with a const pointer to an object. It is const
I have a dictionary that goes like this: typedef struct dictNode { int key;
I have a member pointer with this type: const TopState<TestHSM>* state_; state_ is of
I have a const int that is computed at compile time in my Managed
In Form1.cs i have public const int n = 30; public TabPage[] tp =
I have: typedef void (*RespExtractor) (const cv::Mat & image, cv::Mat & resp); virtual void
I have a pointer int* p , and do some operations in a loop.
I have a C++ struct and a method: struct Account { unsigned int id;

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.