[Rcpp-devel] Bizarre Rcpp::XPtr problem on GCC

Kevin Thornton krthornt at uci.edu
Thu May 21 03:00:36 CEST 2015


I claim that I’ve provided it, so I’m assuming that the delivery (gist) is the problem.  So, here’s a copy/paste for you.  Without the custom deleter, this fails to link using GCC 4.7/4.8/4.9 with Rcpp 0.11.4 and newer.

The problem is the combination of the typedef and the function foo being a template.  Change either one of those, and all is ok (on GCC—all is fine on clang).

This example is contrived to reproduce the failure to create the XPtr’s deleter on GCC.  The original context can be seen in this diff: https://github.com/molpopgen/foRward/commit/880c0c4e4caf2e9e0b5f7263720ebcca608a6059

#include <Rcpp.h>
#include <tuple>

#ifdef USE_DELETER
namespace Rcpp {
  template<>
  inline void standard_delete_finalizer<std::tuple<int,int> >( std::tuple<int,int> * t ) { delete t; }
}
#endif

namespace foo {
  using tuple_t = std::tuple<int,int>;
  template<typename T>
  SEXP foofunc(const T & a)
  {
    return Rcpp::XPtr<tuple_t>(new tuple_t(a,a));
  }
}

SEXP foofunc_caller(const int & a) { return foo::foofunc(a); }

> On May 20, 2015, at 5:50 PM, Hao Ye <hye at ucsd.edu> wrote:
> 
> Kevin, 
> 
> I think Dirk is looking for a MWE (minimal working example).
> 
> Best,
> --
> Hao Ye
> hye at ucsd.edu
> 
>> On May 20, 2015, at 5:35 PM, Kevin Thornton <krthornt at uci.edu> wrote:
>> 
>> Dirk,
>> 
>> What are you asking for?  I provided a working source file + the Rscripts I used to identify the problem + ample comments about how I arrived at it.  I’m not sure how this qualifies as “random snippets."
>> 
>> —Kevin
>> 
>>> On May 20, 2015, at 5:20 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
>>> 
>>> 
>>> On 20 May 2015 at 15:22, Kevin Thornton wrote:
>>> | Hi,
>>> | 
>>> | I’m currently working on a header-only library that it intended to act as a
>>> | “glue" layer between an existing C++11 library (also header only) and R, by
>>> | means of Rcpp.
>>> | 
>>> | Basically, I am trying to provide some generic templates that perform
>>> | operations using the existing C++11 library and return appropriate data objects
>>> | to the R environment.
>>> | 
>>> | My current plan for this library is that:
>>> | 
>>> | 1. It is also c++11
>>> | 2. It exists in its own namespace
>>> | 
>>> | Rcpp seems to have problems with the latter, but only on GCC.
>>> 
>>> I think I we do have a few counterexamples to that claim.
>>> 
>>> That said, it of course entirely possible that have found a bug, but I don;t
>>> currently have time to follow links to random gists with random snippets of
>>> code.
>>> 
>>> If there is a genuine bug we may get to a proper bug report in due course.
>>> Or so one hopes.
>>> 
>>> Dirk
>>> 
>>> -- 
>>> http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
>> 
>> _______________________________________________
>> Rcpp-devel mailing list
>> Rcpp-devel at lists.r-forge.r-project.org
>> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
> 



More information about the Rcpp-devel mailing list