Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link in [expr.call]/6 is probably wrong. It should be [expr.reinterpret.cast] instead of [dcl.link]. #2482

Closed
jabelloc opened this issue Nov 16, 2018 · 5 comments · Fixed by #2863
Assignees

Comments

@jabelloc
Copy link

[expr.call]/6:

Calling a function through an expression whose function type is different from the function type of the called function's definition results in undefined behavior ([dcl.link]).

[expr.reinterpret.cast]/6 :

A function pointer can be explicitly converted to a function pointer of a different type. [ Note: The effect of calling a function through a pointer to a function type ([dcl.fct]) that is not the same as the type used in the definition of the function is undefined. — end note ] Except that converting a prvalue 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 [conv.ptr] for more details of pointer conversions. — end note ]

@CaseyCarter
Copy link
Contributor

Related: is it intended that calling anoexcept function through a pointer-to-non-noexcept-function results in undefined behavior?

@jensmaurer
Copy link
Member

@jabelloc, [dcl.linik]p1 says "Two function types with different language linkages are distinct types even if they are otherwise identical." So, the cross-reference points at one possible (and not super-obvious) way how you can screw up.
@CaseyCarter, that seems to be a defect in the wording. I'd suggest to ask for a core issue on the CWG reflector.

@CaseyCarter
Copy link
Contributor

I'd suggest to ask for a core issue on the CWG reflector.

Done. Apologies for injecting obviously-non-editorial questions in the editorial issue tracker. I should know better.

@cpplearner
Copy link
Contributor

cpplearner commented Nov 17, 2018

Per [basic.link]/11 it's ill-formed NDR to declare the same function with different types. So one already screw up before they invoke that function.

@jensmaurer jensmaurer added the decision-required A decision of the editorial group (or the Project Editor) is required. label Nov 27, 2018
@jensmaurer
Copy link
Member

Editorial meeting:

  • Remove the dcl.link cross-reference.
  • expr.reinterpret.cast needs a cross-reference to expr.call at the end of the first note.

@jensmaurer jensmaurer removed the decision-required A decision of the editorial group (or the Project Editor) is required. label Feb 22, 2019
@jensmaurer jensmaurer self-assigned this May 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants