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::invoke fails to call noexcept marked function #36755

Closed
llvmbot opened this issue May 10, 2018 · 2 comments
Closed

std::invoke fails to call noexcept marked function #36755

llvmbot opened this issue May 10, 2018 · 2 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 10, 2018

Bugzilla Link 37407
Resolution FIXED
Resolved on May 12, 2018 05:47
Version unspecified
OS Linux
Reporter LLVM Bugzilla Contributor
CC @mclow

Extended Description

std::invoke wrongly takes the partial specialization for objects instead for functions for functions marked with noexcept. I'm on r331914.

#include

void func() noexcept {}

int main() { std::invoke(func); }

Here's the full error message:

In file included from main.cpp:1:
In file included from /usr/local/bin/../include/c++/v1/functional:484:
/usr/local/bin/../include/c++/v1/type_traits:4196:19: error: invalid application of 'sizeof' to a function type
static_assert(sizeof(_Tp) > 0, Type must be complete.);
^~~~~~~~~~~
/usr/local/bin/../include/c++/v1/type_traits:4201:15: note: in instantiation of template class 'std::__1::__check_complete<void () noexcept>' requested here
: private __check_complete<_Tp>
^
/usr/local/bin/../include/c++/v1/type_traits:4494:15: note: in instantiation of template class 'std::__1::__check_complete<void (&)() noexcept>' requested here
: private __check_complete<_Fp>
^
/usr/local/bin/../include/c++/v1/type_traits:4557:9: note: in instantiation of template class 'std::__1::__invokable_r<void, void (&)() noexcept>' requested here
__invokable<_Fp, _Args...>::value,
^
/usr/local/bin/../include/c++/v1/type_traits:4566:14: note: in instantiation of template class 'std::__1::__invoke_of<void (&)() noexcept>' requested here
: public __invoke_of<_Fp, _Args...>
^
/usr/local/bin/../include/c++/v1/type_traits:4571:22: note: in instantiation of template class 'std::__1::result_of<void (&())() noexcept>' requested here
template using result_of_t = typename result_of<_Tp>::type;
^
/usr/local/bin/../include/c++/v1/functional:2346:1: note: in instantiation of template type alias 'result_of_t' requested here
result_of_t<_Fn&&(_Args&&...)>
^
main.cpp:5:14: note: while substituting deduced template arguments into function template 'invoke' [with _Fn = void (&)() noexcept, _Args = <>]
int main() { std::invoke(func); }
^
1 error generated.

@llvmbot
Copy link
Collaborator Author

llvmbot commented May 10, 2018

It seems we don't have a proper specialization of __check_complete for noexcept function types.

@llvmbot
Copy link
Collaborator Author

llvmbot commented May 12, 2018

Fixed in r332040 and r332066.

We no longer check for the completeness of types to invoke or similar callable traits. We probably should, but doing it correctly is super expensive, in terms of both compile time and compiler memory usage.

@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