Skip to content

capture parameter pack as a tuple to work around gcc4.8 #71

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

Merged
merged 5 commits into from
Aug 5, 2020

Conversation

bkietz
Copy link
Collaborator

@bkietz bkietz commented Aug 4, 2020

fixes #69

repro: https://wandbox.org/permlink/po7niLIoJ9HgJ74p
fixed: https://wandbox.org/permlink/RTg6mAArF13XyuRU

There are more sophisticated/general implementations of make_index_sequence/apply if desired

@jimhester
Copy link
Member

Great, thanks!

Do you think we should use this new implementation in all cases, or only when older gcc versions are used?

@bkietz
Copy link
Collaborator Author

bkietz commented Aug 4, 2020

There's no performance overhead (runtime or compile time) so I'd say: it's simpler to just leave it this way until gcc 4.8 can be dropped

@jimhester
Copy link
Member

I think we may have to do the same thing with the parameter packs in cpp11::stop and cpp11::warning as well? I get the following errors when trying to compile tidyr with this PR

g++ -std=gnu++11 -I"/opt/R/4.0.2/lib/R/include" -DNDEBUG  -I'/opt/R/4.0.2/lib/R/library/cpp11/include' -I/usr/local/include   -fpic  -g -O2  -c cpp11.cpp -o cpp11.o
In file included from /opt/R/4.0.2/lib/R/library/cpp11/include/cpp11/as.hpp:8:0,
                 from /opt/R/4.0.2/lib/R/library/cpp11/include/cpp11.hpp:5,
                 from /opt/R/4.0.2/lib/R/library/cpp11/include/cpp11/declarations.hpp:8,
                 from cpp11.cpp:4:
/opt/R/4.0.2/lib/R/library/cpp11/include/cpp11/protect.hpp: In lambda function:
/opt/R/4.0.2/lib/R/library/cpp11/include/cpp11/protect.hpp:245:38: error: parameter packs not expanded with ‘...’:
   unwind_protect([&] { Rf_error(fmt, args...); });
                                      ^
/opt/R/4.0.2/lib/R/library/cpp11/include/cpp11/protect.hpp:245:38: note:         ‘args’
/opt/R/4.0.2/lib/R/library/cpp11/include/cpp11/protect.hpp:245:42: error: expansion pattern ‘args’ contains no argument packs
   unwind_protect([&] { Rf_error(fmt, args...); });
                                          ^
/opt/R/4.0.2/lib/R/library/cpp11/include/cpp11/protect.hpp: In lambda function:
/opt/R/4.0.2/lib/R/library/cpp11/include/cpp11/protect.hpp:253:46: error: parameter packs not expanded with ‘...’:
   unwind_protect([&] { Rf_error(fmt.c_str(), args...); });
                                              ^
/opt/R/4.0.2/lib/R/library/cpp11/include/cpp11/protect.hpp:253:46: note:         ‘args’
/opt/R/4.0.2/lib/R/library/cpp11/include/cpp11/protect.hpp:253:50: error: expansion pattern ‘args’ contains no argument packs
   unwind_protect([&] { Rf_error(fmt.c_str(), args...); });
                                                  ^
/opt/R/4.0.2/lib/R/library/cpp11/include/cpp11/protect.hpp: In instantiation of ‘struct cpp11::stop(const char*, Args ...) [with Args = {}]::__lambda3’:
/opt/R/4.0.2/lib/R/library/cpp11/include/cpp11/protect.hpp:245:49:   required from ‘void cpp11::stop(const char*, Args ...) [with Args = {}]’
/opt/R/4.0.2/lib/R/library/cpp11/include/cpp11/as.hpp:98:39:   required from ‘cpp11::is_logical<T> cpp11::as_cpp(SEXP) [with T = bool; cpp11::is_logical<T> = bool; SEXP = SEXPREC*]’
cpp11.cpp:24:452:   required from here
/opt/R/4.0.2/lib/R/library/cpp11/include/cpp11/protect.hpp:245:38: error: using invalid field ‘cpp11::stop(const char*, Args ...)::__lambda3::__args’
   unwind_protect([&] { Rf_error(fmt, args...); });
                                      ^

But this does fix the errors with safe, so I think it is a good workaround.

@bkietz
Copy link
Collaborator Author

bkietz commented Aug 4, 2020

actually, those errors are all from stop(). I think we can just use safe in stop() as we do in warning()

@jimhester
Copy link
Member

jimhester commented Aug 5, 2020

Cool, can confirm these changes fix compilation on 4.8.5, thanks @bkietz for working through this! People will definitely be happy they can use cpp11 on older gcc versions.

@jimhester jimhester merged commit 01cc960 into r-lib:master Aug 5, 2020
@jimhester jimhester deleted the parameter-pack-to-tuple-for-gcc4.8 branch August 5, 2020 15:27
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

Successfully merging this pull request may close these issues.

gcc 4.8.5 compatibility
2 participants