knausb / vcfR

Tools to work with variant call format files
248 stars 54 forks source link

compilation issue #209

Closed knausb closed 1 year ago

knausb commented 1 year ago

On 2023-01-26 I was made aware that vcfR now has compile time issues.

[gcc12](https://www.stats.ox.ac.uk/pub/bdr/gcc12/vcfR.out)
Check Details

Version: 1.13.0
Check: whether package can be installed
Result: WARN
    Found the following significant warnings:
     ad_frequency.cpp:122:43: warning: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result]
     masplit.cpp:152:43: warning: ignoring return value of function declared with 'nodiscard' attribute [-Wunused-result]
    See ‘/home/hornik/tmp/R.check/r-devel-clang/Work/PKGS/vcfR.Rcheck/00install.out’ for details.
    * used C++ compiler: ‘Debian clang version 15.0.6’
Flavor: [r-devel-linux-x86_64-debian-clang](https://www.r-project.org/nosvn/R.check/r-devel-linux-x86_64-debian-clang/vcfR-00check.html)

We have been given until 2023-02-10 to resolve this by CRAN.

I was not able to reproduce this on my local Ubuntu system with

$ gcc --version gcc (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0

and

R version 4.2.2 Patched (2022-11-10 r83330) -- "Innocent and Trusting"

Thinking I'll need to upgrade to gcc12 to reproduce this?

knausb commented 1 year ago

Was able to reproduce the warning using docker.

CMD="sudo docker run \
  --name=my-r-devel \
  --rm \
  -ti \
  -v /home/knausb/gits/tmp:/RSource \
  rocker/r-devel \
  /bin/bash"
echo $CMD
eval $CMD

This resulted in the following.

# cat /etc/*-release
PRETTY_NAME="Debian GNU/Linux bookworm/sid"
NAME="Debian GNU/Linux"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
# less vcfR.Rcheck/00install.out 
* installing *source* package ‘vcfR’ ...
** using staged installation
** libs
using C++ compiler: ‘g++ (Debian 12.2.0-14) 12.2.0’
g++ -std=gnu++17 -I"/usr/local/lib/R/include"

And.

# less vcfR.Rcheck/00check.log
* using log directory ‘/RSource/vcfR.Rcheck’
* using R Under development (unstable) (2023-01-29 r83721)
* using platform: x86_64-pc-linux-gnu (64-bit)
* R was compiled by
    gcc (Debian 12.2.0-14) 12.2.0
    GNU Fortran (Debian 12.2.0-14) 12.2.0

Resulting in.

# less vcfR.Rcheck/00install.out
ad_frequency.cpp: In function ‘Rcpp::NumericMatrix AD_frequency(Rcpp::StringMatrix, std::string, unsigned int, int, int)’:
ad_frequency.cpp:122:55: warning: ignoring return value of ‘std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::__cxx11::basic_string<char>; _Alloc = std::allocator<std::__cxx11::basic_string<char> >; size_type = long unsigned int]’, declared with attribute ‘nodiscard’ [-Wunused-result]
  122 |         std::vector < float > float_vec;( col_vec.size(), 0);
      |                                           ~~~~~~~~~~~~^~
In file included from /usr/include/c++/12/vector:64,
                 from /usr/local/lib/R/site-library/Rcpp/include/RcppCommon.h:60,
                 from /usr/local/lib/R/site-library/Rcpp/include/Rcpp.h:27,
                 from ad_frequency.cpp:1:
/usr/include/c++/12/bits/stl_vector.h:987:7: note: declared here
  987 |       size() const _GLIBCXX_NOEXCEPT
      |       ^~~~

Which appears to match the behavior reported by CRAN.

knausb commented 1 year ago

Changed

std::vector < float > float_vec;( col_vec.size(), 0);

to

std::vector < float > float_vec ( sizeof(col_vec) );

in ad_frequency.cpp and masplit.cpp.