[Rcpp-devel] strange bool conversion?

Dirk Eddelbuettel edd at debian.org
Mon Jan 10 15:33:12 CET 2011


On 10 January 2011 at 15:27, Romain Francois wrote:
| Le 10/01/11 13:26, Dirk Eddelbuettel a écrit :
| >
| > On 10 January 2011 at 12:06, Daniel Sabanés Bové wrote:
| > | Hi,
| > |
| > | I have to report another serious bug in argument extraction, now with
| > | integers.
| > | (It seems to me that the fix by Romain could have been causing this
| > | behaviour?)
| > | Moreover, the problem does not depend on a "const" modifier:
| > |
| > | -- snip --
| > |
| > | library(Rcpp)
| > | library(inline)
| > |
| > | ## this compiles and loads fine, but is wrong:
| > | wrong<- cxxfunction(signature(x="list") , '
| > |          List input(x);
| > |          int a = input[0];
| > |          return wrap(a);
| > |          ' , plugin = "Rcpp")
| > |
| > | ## still OK:
| > | wrong(list(1))
| > |
| > | ## all 1:
| > | wrong(list(4))
| > | wrong(list(4L))
| > | wrong(list(-4L))
| > |
| > |
| > | ## this is correct:
| > | correct<- cxxfunction(signature(x="list") , '
| > |          List input(x);
| > |          int a = as<int>(input[0]);
| > |          return wrap(a);
| > |          ' , plugin = "Rcpp")
| > |
| > | correct(list(1))
| > | wrong(list(4))
| > | wrong(list(4L))
| > | wrong(list(-4L))
| > |
| > | -- snap --
| >
| > So where is the bug?
| 
| This is a bug and I'll fix it. Things are supposed to work here without 
| the explicit conversion and this has been advertised as such.

Ok, then I stand corrected. Guess I have gotten too used to having be
explicit in the template use.

So where do promise what exactly?  

All basic types recognised correctly with implicit templates?  I guess in
that case I should help plugging some holes in the unit tests.

Dirk

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com


More information about the Rcpp-devel mailing list