[Rcpp-devel] Rcpp function results are different on different systems

Naeem Khoshnevis khoshnevis.naeem at gmail.com
Thu Aug 19 04:17:54 CEST 2021


Dear all,


I wrote a function using Rcpp; it is a simple function; however, it
significantly improves the performance. I realized that on some systems,
the result of the function is different from others.


For example, on the following systems (on rhub), the results are identical
and are correct:

   - Fedora Linux, R-devel, clang, gfortran (fedora-clang-devel)
   - macOS 10.13.6 High Sierra, R-release, brew (macos-highsierra-release)
   - Windows Server 2008 R2 SP1, R-devel, 32/64 bit (windows-x86_64-devel)

However, on the following systems (on rhub), the results are different:

   -  Ubuntu Linux 20.04.1 LTS, R-devel, GCC (ubuntu-gcc-devel)


Here is the error:


Running the tests in ‘tests/testthat.R’ failed.

   Last 13 lines of output:

     val[1] not equal to 4.

     1/1 mismatches

     [1] 2 - 4 == -2

     ── Failure (test-compute_closest_wgps_helper.R:12:3):
compute_closest_wgps_helper works as expected. ──

     val[3] not equal to 3.

     1/1 mismatches

     [1] 1 - 3 == -2

     ── Failure (test-compute_closest_wgps_helper.R:13:3):
compute_closest_wgps_helper works as expected. ──

     val[4] not equal to 1.

     1/1 mismatches

     [1] 2 - 1 == 1



     [ FAIL 3 | WARN 0 | SKIP 0 | PASS 69 ]


As much as I can check the code, it looks correct. But I am not sure what
else I can check. Some package users claimed that different R versions
provide different results; however, I checked it on r-base=3.6, 4.0, 4.1
and received the same correct results (macOS 11.2).

I would be grateful if you could let me know your thoughts about this issue.


Here is the source code:

https://github.com/fasrc/CausalGPS/blob/97342ecc90fd20f2c7c4458a70aefe471b09510c/src/compute_closest_wgps_helper.cpp


Here is the related test:

https://github.com/fasrc/CausalGPS/blob/97342ecc90fd20f2c7c4458a70aefe471b09510c/tests/testthat/test-compute_closest_wgps_helper.R



Best regards,

Naeem Khoshnevis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20210818/bc56002e/attachment-0001.html>


More information about the Rcpp-devel mailing list