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

Bug fix: Function pointer can't be used to create a proxy #50

Merged
merged 2 commits into from
Dec 26, 2023

Conversation

mingxwa
Copy link
Collaborator

@mingxwa mingxwa commented Dec 25, 2023

Work item: #49

The root cause of the bug is that std::to_address() does not support function pointers. Per its wording in [pointer.conversion]

template<class T> constexpr T* to_address(T* p) noexcept;
  Mandates: T is not a function type.
  Returns: p.

Checking the history of the proposal P0653R2, this prerequisite was added per LWG review comments:

This is meant only for turning a maybe-smart pointer type to a definitely-raw pointer, if it starts being used for "get address of a function" or "get address of first element of array" so maybe we do want to have deleted overloads for them.

While there seems to be little reason for proxy to reject function pointers, this restriction was bypassed in this change. Some unit test cases were added accordingly.

@mingxwa mingxwa requested a review from tian-lt December 25, 2023 03:40
@mingxwa mingxwa merged commit 30c87ef into microsoft:main Dec 26, 2023
4 checks passed
@mingxwa mingxwa deleted the user/mingxwa/function-pointer branch December 26, 2023 13:30
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 this pull request may close these issues.

2 participants