Rcpp: Platform differences in output

357 views Asked by At

i have the following problem (and cannot really produce a minimal test)-- i am porting a package from C++ via Rcpp to R. the tests (i am testing if the output matrix is exactly what i would get if calling c++ directly) under linux and osx are absolutely equal, no difference.

but when testing either via build_win() or via a win 8.1 virtual machine i get different results (but the results between both are consistent, so i have linux/osx vs win results) i already replaced the one rand() call with the corresponding Rcpp sugar, so this should be no problem (i hope at least). as calling the tests via "R -d valgrind" also produce no error, i am a bit puzzled how to proceed. all tests are done with R 3.2.0 (local machines) and latest unstable (via build_win()) so my questions are:

  • are there any known Rcpp differences when compiling (e.g. the compiler provided by Rtools on windows is too old and therefore numeric computations (using STL, no other library like boost/eigen etc) are expected to be slightly different?
  • is there a good way to debug the problem? i would need to trace basically the C++ code line by line, i am even not sure how to do that except for heavy std::couts.

thanks.

1

There are 1 answers

3
complexM On

the truth about the 32bit/64bit problem is indeed written up here different behaviour or sqrt when compiled with 64 or 32 bits

adding the -ffloat-store option did fix my problem. never expected that, thought the problem is in the source code.