[Rcpp-devel] Sugar: This is not just a windows issue (partial fix): was sugar under Windows/g++ (MinGW) odd behavior.

Dominick Samperi djsamperi at gmail.com
Tue Jan 25 02:58:01 CET 2011


I reported a problem in another thread that I thought only surfaced
under Windows,
but I was wrong (see Subject line). The problem also appears under GCC 4.5+,
and it appears that somebody already noticed problems with this version of GCC
and introduced the compiler define IS_GCC_450_OR_LATER to navigate
around the problematic code.

After some debugging, and based on the links that I posted in the original
thread, the problem seems to be due to the more recent versions of the
compilers GCC 4.5+ and VC++ 2010 introducing support for new reference
features that will not become official until C++0x is released later
this year (or in 2012).

A partial fix that enables my test drivers to work is to replace
reference variables by non-references variables in constructors like
Plus_Vector_Vector. Specifically, the declarations

const LHS_EXT& lhs;
const RHS_EXT& rhs;

should be replaced with

const LHS_EXT lhs;
const RHS_EXT rhs;

This is a partial fix because I have not checked that this doesn't cause
other problems with expression evaluation, but it is a start...

The problem with the original code is that the references lhs and rhs
are initialized to point to a temporary that disappears when the
constructor exits. This work-around simply saves a copy instead of
saving a reference.

Dominick


More information about the Rcpp-devel mailing list