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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:03:47+00:00 2026-05-27T09:03:47+00:00

(5.2.10/6) C++03 A pointer to a function can be explicitly converted to a pointer

  • 0

(5.2.10/6) C++03 A pointer to a function can be explicitly converted to a pointer to a function of a different type. The effect of calling a function
through a pointer to a function type (8.3.5) that is not the same as
the type used in the definition of the function is undefined. Except
that converting an rvalue of type “pointer to T1” to the type “pointer
to T2” (where T1 and T2 are function types) and back to its original
type yields the original pointer value, the result of such a pointer
conversion is unspecified. [Note: see also 4.10 for more details of
pointer conversions.]

The following is what I’m trying to do, while it is clear that the result of converting fp1 to fp2 will produce a original pointer but at the same point the wording in standard goes "The result of such a pointer conversion is unspecified" What does it mean by that?

int f() { return 42; }

int main()
{
    void(*fp1)() = reinterpret_cast<void(*)()>(f);

    int(*fp2)() = reinterpret_cast<int(*)()>(fp1);

    // Safe to call the function ?
    fp2();
}
  • 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-27T09:03:48+00:00Added an answer on May 27, 2026 at 9:03 am

    You are misreading the standard, the “unspecified” part only applies to other conversions:

    Except [special case] the result of such a pointer conversion is unspecified.

    That [special case] is the one where you convert back to the original function pointer type, like in your example. In this special case the conversions yield the original pointer value, so it’s ok to use it like in your example.

    Only for other conversions the result is unspecified.

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

Sidebar

Related Questions

You can pass a function pointer, function object (or boost lambda) to std::sort to
Can we say passing a function pointer as an argument to a function is
in C++, I can easily create a function pointer by taking the address of
Can I pass this to a function as a pointer, from within the class
I need an array to hold member-function-pointers of different classes. How can I define
I have need for a function pointer that takes two arguments and returns a
I am working with a COM plugin interface that has the following function definition:
I can create function pointers in Fortran 90, with code like real, external ::
Are function pointers supported in Inno Setup? I can't find anything in the documentation.
I have a function pointer defined by: typedef void (*EventFunction)(int nEvent); Is there a

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.