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

Incorrect type signature code #4

Closed
berkus opened this issue Dec 22, 2016 · 2 comments
Closed

Incorrect type signature code #4

berkus opened this issue Dec 22, 2016 · 2 comments

Comments

@berkus
Copy link

berkus commented Dec 22, 2016

Hi!

The code in

template < class R, class... Args >
struct TypeSignature< R (Args...) >
{
private:
template < class... T > void DoNothingWith( T&&... ) const {}
std::string Compute() const
{
static std::string result("(");
DoNothingWith( ( result += TypeSignature<Args>()() )... );
result += ")";
result += TypeSignature<R>()();
return result;
}
is incorrect.

It passes argument pack expansion as arguments to the function DoNothingWith(). Per standard compiler is free to arrange function arguments computation in any order - and gcc and clang disagree here. Clang computes arguments left to right, producing correct signature; android gcc 4.9 computes them right to left, producing completely invalid function signature.

You can verify it here

@jfirebaugh
Copy link
Contributor

Thanks for the report! Since writing that code I learned a better technique for pack expansion but I forgot to port it to jni.hpp.

@berkus
Copy link
Author

berkus commented Dec 25, 2016

Yay, thanks for prompt fix!

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

No branches or pull requests

2 participants