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

std::function doesn't recognize null pointer to varargs function #23963

Closed
llvmbot opened this issue May 20, 2015 · 3 comments
Closed

std::function doesn't recognize null pointer to varargs function #23963

llvmbot opened this issue May 20, 2015 · 3 comments
Labels
bugzilla Issues migrated from bugzilla libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented May 20, 2015

Bugzilla Link 23589
Resolution FIXED
Resolved on Aug 19, 2015 01:58
Version 3.6
OS All
Reporter LLVM Bugzilla Contributor
CC @mclow

Extended Description

This crashes:

#include

void (*p)(...) = nullptr;
std::function< void() > f = p;

int main() {
try { f(); }
catch ( std::bad_function_call & ) {}
}

The problem is missing overloads of std::function::__not_null.

On a related note, I'm working on a std::function extension. Is there no facility for function signature decomposition?

@llvmbot
Copy link
Collaborator Author

llvmbot commented May 20, 2015

Looks like __not_null is missing quite a few overloads. Patch up for review as D9873 (http://reviews.llvm.org/D9873).

@llvmbot
Copy link
Collaborator Author

llvmbot commented May 20, 2015

I created an account and left a comment in the review, but it still says "waiting for moderator approval."

A lot of work can be saved by ignoring the function signature.

template<class _R2, class _Cp>
static bool not_null(_R2 _Cp::*__p) {return __p;}

--
Actually, you should only need three overloads: one for pointers (including varargs function pointers), one for PTMs (effectively PTMFs but ignoring the function aspects), and the one which is always true.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Aug 19, 2015

Fixed in r245335.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

No branches or pull requests

1 participant