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

Compilation issue with Visual Studio 2015 CTP #2

Closed
samhocevar opened this issue Jan 22, 2015 · 6 comments
Closed

Compilation issue with Visual Studio 2015 CTP #2

samhocevar opened this issue Jan 22, 2015 · 6 comments
Assignees

Comments

@samhocevar
Copy link
Contributor

The VS2015 technology preview is the only version that almost manages to build PEGTL. However, it fails to understand the decltype+comma SFINAE trick in rule_match_call.hh:

1>c:\users\sam\pegtl\pegtl\internal\rule_match_call.hh(26): error C2535: 'unknown-type
    pegtl::internal::rule_match_call<Rule,E,Action,Control>::match(Input &,States &&...)':
    member function already defined or declared
1>c:\users\sam\pegtl\pegtl\internal\rule_match_call.hh(17): note: see declaration of
    'pegtl::internal::rule_match_call<Rule,E,Action,Control>::match'
1>c:\users\sam\pegtl\pegtl\internal\rule_match_call.hh(27): note: see reference to class
    template instantiation 'pegtl::internal::rule_match_call<Rule,E,Action,Control>' being
    compiled

Even though this is a compiler bug, do you think a workaround is possible? I have tried a few things but failed to come up with something that works.

@d-frey d-frey self-assigned this Jan 22, 2015
@d-frey
Copy link
Member

d-frey commented Jan 22, 2015

Please report a bug against Visual C++ if you haven't done so already.

As a work-around, please try to include <type_traits> and use

typename std::enable_if< sizeof( Rule::template match< E, Action, Control >( in, st ... ) ) != 0, bool >::type

as the first trailing return type and

typename std::enable_if< sizeof( Rule::match( in ) ) != 0, bool >::type

for the second. If that helps, I'd be willing to change the code to this uncool version :)

If it doesn't help, I can't do much as I don't have Visual C++. Of course, if you can come up with some other reasonable work-around, we'll look into it.

@samhocevar
Copy link
Contributor Author

I have created a minimal test case and posted a bug report to Microsoft. I only have limited access to a Windows computer so I haven’t yet found a workaround. I will try your suggestion though, but I seem to remember trying something like that and it didn’t work because of sizeof actually returning a fatal error.

Note by the way that if you have access to Windows, the Visual Studio technology previews can be downloaded freely.

@d-frey
Copy link
Member

d-frey commented Jan 29, 2015

I don't have Windows, so the free download of Visual Studio won't help me.

For now, I'm closing this issue as the bug is in the compiler of VS, not in our code. If you can come up with a viable work-around, please don't hesitate to let us know about it.

@d-frey d-frey closed this as completed Jan 29, 2015
@d-frey d-frey added the wontfix label Jan 29, 2015
@d-frey
Copy link
Member

d-frey commented Jan 31, 2015

Sam,

can you please try to add a defaulted dummy template parameter to the second overload? Like this:

template< typename Input, typename ... States, int = 0 >
static auto match( Input & in, States && ... ) -> decltype( Rule::match( in ), bool() )
...

(but note: Just for the second overload!)

Thanks in advance!

@samhocevar
Copy link
Contributor Author

Ah that’s clever! It did the trick, thanks.

@d-frey d-frey removed the help wanted label Feb 2, 2015
@d-frey
Copy link
Member

d-frey commented Feb 2, 2015

Work-around committed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants