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

Fix noexcept specialization on function pointers #141

Closed
mmha opened this issue May 28, 2017 · 3 comments
Closed

Fix noexcept specialization on function pointers #141

mmha opened this issue May 28, 2017 · 3 comments
Labels

Comments

@mmha
Copy link

mmha commented May 28, 2017

I just (indirectly) tried to use your library. Unfortunately, the specialization on noexcept of function pointers (#89) does not work on clang:

template<typename T>
struct S;

template<bool IsNoexcept>
struct S<void(*)() noexcept(IsNoexcept)> {
	S() {}
};

void f() {}

int main() {
	S<decltype(&f)> {};
}

Clang output:

struct S<void(*)() noexcept(IsNoexcept)> {
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
example.cpp:4:15: note: non-deducible template parameter 'IsNoexcept'
template<bool IsNoexcept>
              ^
example.cpp:12:2: error: implicit instantiation of undefined template 'S<void (*)()>'
        S<decltype(&f)> {};
        ^
example.cpp:2:8: note: template is declared here
struct S;
       ^

In fact, just including callable_traits causes clang to emit those errors in C++17 mode. The same code crashes gcc, removing the constructor is a workaround and results in a successful compilation.

I cannot back it up with a reference to the standard, but the clang implementation suggests that this is not legal C++17. I don't trust the gcc implementation in that regard because of the bug I found.

@badair
Copy link
Collaborator

badair commented May 29, 2017

Thank you for the report; this is quite unfortunate. I asked about this here. libstdc++ uses this technique for its definition of is_function, which makes me think this is a QOI issue that I'll need to work around.

Relates to #85

@badair badair added the bug label May 29, 2017
@badair
Copy link
Collaborator

badair commented May 29, 2017

I used this technique to cut down on the amount of preprocessed text in half when compiling with c++1z. I'll start working to revert this optimization, but it will increase the preprocessed LOC from 20k to 40k :(

@badair
Copy link
Collaborator

badair commented May 29, 2017

closed via e310b2b. Bumped version to 2.0.0 which includes all post-review changes so far.

@badair badair closed this as completed May 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants