bschneidr / fastsurvey

A fork of the `survey` R package, using {Rcpp}
7 stars 0 forks source link

R CMD check issues with C++ code #8

Closed bschneidr closed 1 year ago

bschneidr commented 1 year ago

From Thomas:

R CMD check also gives some warnings about the C++ code that presumably were added to the check since you wrote the code. I don't know about the self-assign ones, but the the logical operator ones seem to be on point but also harmless.

  arma_multistage.cpp:102:48: warning: use of bitwise '|' with boolean operands [-Wbitwise-instead-of-logical]
  arma_multistage.cpp:106:14: warning: use of bitwise '&' with boolean operands [-Wbitwise-instead-of-logical]
  arma_multistage.cpp:115:50: warning: use of bitwise '|' with boolean operands [-Wbitwise-instead-of-logical]
  arma_multistage.cpp:132:9: warning: use of bitwise '&' with boolean operands [-Wbitwise-instead-of-logical]
  arma_multistage.cpp:152:9: warning: use of bitwise '&' with boolean operands [-Wbitwise-instead-of-logical]
  arma_multistage.cpp:276:33: warning: explicitly assigning value of variable of type 'arma::mat' (aka 'Mat<double>') to itself [-Wself-assign-overloaded]
  arma_multistage.cpp:281:48: warning: explicitly assigning value of variable of type 'Rcpp::CharacterVector' (aka 'Vector<16>') to itself [-Wself-assign-overloaded]
  arma_multistage.cpp:282:64: warning: explicitly assigning value of variable of type 'Rcpp::LogicalVector' (aka 'Vector<10>') to itself [-Wself-assign-overloaded]
  arma_multistage.cpp:283:37: warning: explicitly assigning value of variable of type 'int' to itself [-Wself-assign]

The bitwise operator warnings are quick fixes. I'll look into the self-assign warnings to see whether I need to add a checking step to each self-assignment, or if I have to get rid of the self-assignment entirely.

bschneidr commented 1 year ago

The warnings about bitwise operators are fixed by 399e7c6

bschneidr commented 1 year ago

For more detail on this, I ran devtools::check_mac_release(manual = FALSE, vignettes = FALSE), since I wasn't seeing these C++ warnings on my Windows machine. Here's the relevant warnings in 00install.out:

https://mac.r-project.org/macbuilder/results/1693150893-6ceed2f01ca8d6e0/

using C++ compiler: ‘Apple clang version 14.0.3 (clang-1403.0.22.14.1)’
using SDK: ‘MacOSX11.3.sdk’
clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Volumes/Builds/templates/cran-build/big-sur-arm64/Rlib/4.3/Rcpp/include' -I'/Volumes/Builds/templates/cran-build/big-sur-arm64/Rlib/4.3/RcppArmadillo/include' -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -c RcppExports.cpp -o RcppExports.o
clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG  -I'/Volumes/Builds/templates/cran-build/big-sur-arm64/Rlib/4.3/Rcpp/include' -I'/Volumes/Builds/templates/cran-build/big-sur-arm64/Rlib/4.3/RcppArmadillo/include' -I/opt/R/arm64/include    -fPIC  -falign-functions=64 -Wall -g -O2  -c arma_multistage.cpp -o arma_multistage.o
arma_multistage.cpp:280:33: warning: explicitly assigning value of variable of type 'arma::mat' (aka 'Mat') to itself [-Wself-assign-overloaded]
  arma::mat V = arma_onestage(Y = Y,
                              ~ ^ ~
arma_multistage.cpp:285:48: warning: explicitly assigning value of variable of type 'Rcpp::CharacterVector' (aka 'Vector<16>') to itself [-Wself-assign-overloaded]
                              singleton_method = singleton_method,
                              ~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~
arma_multistage.cpp:286:64: warning: explicitly assigning value of variable of type 'Rcpp::LogicalVector' (aka 'Vector<10>') to itself [-Wself-assign-overloaded]
                              use_singleton_method_for_domains = use_singleton_method_for_domains,
                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arma_multistage.cpp:287:37: warning: explicitly assigning value of variable of type 'int' to itself [-Wself-assign]
                              stage = stage);
                              ~~~~~ ^ ~~~~~

So I think the culprit is here:

https://github.com/bschneidr/fastsurvey/blob/5e4df7bd6c4bac44fa9c6681db40c496dd701f45/src/arma_multistage.cpp#L276-L283

bschneidr commented 1 year ago

This was an erroneous warning, caused by the fact that the argument names for arma_onestage() are the same as object names in some cases.