diff --git a/.github/workflows/werror.yml b/.github/workflows/werror.yml index 152d6e89d..751a9847e 100644 --- a/.github/workflows/werror.yml +++ b/.github/workflows/werror.yml @@ -8,7 +8,7 @@ on: env: _R_CHECK_FORCE_SUGGESTS_: "false" - RCPP_CXXFLAGS: "-Werror -Wall -Wextra" + RCPP_CXXFLAGS: "-Werror -Wall -Wextra -Wconversion" jobs: ci: diff --git a/ChangeLog b/ChangeLog index ae20b532b..cb582cc3f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,50 @@ +2026-09-05 Iñaki Ucar + + * .github/workflows/werror.yaml: Add -Wconversion + + * inst/include/Rcpp/macros/interface.h: Mark GenericProxy constructor as + explicit to resolve ambiguities with validated SEXP constructors + * inst/include/Rcpp/vector/Vector.h: Idem + * inst/include/Rcpp/DataFrame.h: Idem with ad hoc constructor + * inst/include/Rcpp/vector/ListOf.h: In this case, the implicit conversion + of ListOf e.g. from List is intentional, so the previously generic + constructor now gets restricted to cases that are convertible to SEXP + + * inst/include/Rcpp/stats/dpq/dpq.h: Expand and homogenize R_xlen_t use + * inst/include/Rcpp/sugar/functions/head.h: Idem + * inst/include/Rcpp/vector/MatrixColumn.h: Idem + * inst/include/Rcpp/vector/MatrixRow.h: Idem + * inst/include/Rcpp/vector/RangeIndexer.h: Idem + * inst/include/Rcpp/internal/wrap.h: Idem and fix potential integer overflow + * inst/include/Rcpp/sugar/operators/Comparator_With_One_Value.h: Idem and + fix a bug where rhs_is_na may return NaN instead of NA_INTEGER + * inst/include/Rcpp/Language.h: Revert incorrect use of R_xlen_t + * inst/include/Rcpp/vector/SubMatrix.h: Idem, because Matrix rows and cols + are restricted to int anyway + + * src/date.cpp: Add missing explicit integer narrowing + * inst/tinytest/cpp/dates.cpp: Add static_cast to time_t + * inst/tinytest/cpp/language.cpp: Fix implicit cast to int + * inst/tinytest/cpp/Matrix.cpp: Idem + * inst/tinytest/cpp/Module.cpp: Idem + * inst/tinytest/cpp/String.cpp: Idem + * inst/tinytest/cpp/Vector.cpp: Idem + * inst/include/Rcpp/vector/Matrix.h: Idem + * inst/include/Rcpp/vector/Vector.h: Idem + * inst/include/Rcpp/sugar/Range.h: Idem + * inst/include/Rcpp/sugar/functions/seq_along.h: Idem + * inst/include/Rcpp/sugar/functions/rowSums.h: Idem + * inst/include/Rcpp/sugar/functions/sample.h: Idem + * inst/include/Rcpp/sugar/matrix/col.h: Idem + * inst/include/Rcpp/sugar/matrix/diag.h: Idem + * inst/include/Rcpp/sugar/matrix/lower_tri.h: Idem + * inst/include/Rcpp/sugar/matrix/outer.h: Idem + * inst/include/Rcpp/sugar/matrix/row.h: Idem + * inst/include/Rcpp/sugar/matrix/upper_tri.h: Idem + * inst/include/Rcpp/sugar/functions/var.h: Add static_cast to double + * inst/include/Rcpp/vector/Subsetter.h: Add several necessary static_cast + * inst/include/Rcpp/vector/MatrixBase.h: Idem + 2026-09-04 Dirk Eddelbuettel * DESCRIPTION (Version, Date): Roll micro version and date diff --git a/inst/include/Rcpp/DataFrame.h b/inst/include/Rcpp/DataFrame.h index 65a81576f..e93a05d1b 100644 --- a/inst/include/Rcpp/DataFrame.h +++ b/inst/include/Rcpp/DataFrame.h @@ -1,7 +1,8 @@ // DataFrame.h: Rcpp R/C++ interface class library -- data frames // -// Copyright (C) 2010 - 2026 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2010 - 2025 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2026 Dirk Eddelbuettel, Romain Francois and Iñaki Ucar // // This file is part of Rcpp. // @@ -46,7 +47,8 @@ namespace Rcpp{ set__(other) ; } - template + template ::value, int>::type = 0> DataFrame_Impl( const T& obj ) ; DataFrame_Impl& operator=( DataFrame_Impl& other){ diff --git a/inst/include/Rcpp/Language.h b/inst/include/Rcpp/Language.h index d893df67a..88df9544f 100644 --- a/inst/include/Rcpp/Language.h +++ b/inst/include/Rcpp/Language.h @@ -2,6 +2,7 @@ // Language.h: Rcpp R/C++ interface class library -- language objects (calls) // // Copyright (C) 2010 - 2025 Dirk Eddelbuettel and Romain Francois +// Copyright (C) 2026 Dirk Eddelbuettel, Romain Francois and Iñaki Ucar // // This file is part of Rcpp. // @@ -189,7 +190,7 @@ namespace Rcpp{ class unary_call : public std::function { public: unary_call( Language call_ ) : call(call_), proxy(call_,1) {} - unary_call( Language call_, R_xlen_t index ) : call(call_), proxy(call_,index){} + unary_call( Language call_, int index ) : call(call_), proxy(call_,index){} unary_call( Function fun ) : call( fun, R_NilValue), proxy(call,1) {} RESULT_TYPE operator()( const T& object ){ @@ -206,7 +207,7 @@ namespace Rcpp{ class binary_call : public std::function { public: binary_call( Language call_ ) : call(call_), proxy1(call_,1), proxy2(call_,2) {} - binary_call( Language call_, R_xlen_t index1, R_xlen_t index2 ) : call(call_), proxy1(call_,index1), proxy2(call_,index2){} + binary_call( Language call_, int index1, int index2 ) : call(call_), proxy1(call_,index1), proxy2(call_,index2){} binary_call( Function fun) : call(fun, R_NilValue, R_NilValue), proxy1(call,1), proxy2(call,2){} RESULT_TYPE operator()( const T1& o1, const T2& o2 ){ diff --git a/inst/include/Rcpp/api/meat/DataFrame.h b/inst/include/Rcpp/api/meat/DataFrame.h index b679e32ab..f73a297f2 100644 --- a/inst/include/Rcpp/api/meat/DataFrame.h +++ b/inst/include/Rcpp/api/meat/DataFrame.h @@ -1,4 +1,5 @@ -// Copyright (C) 2013 Romain Francois +// Copyright (C) 2013 - 2025 Romain Francois +// Copyright (C) 2026 Romain Francois and Iñaki Ucar // // This file is part of Rcpp. // @@ -21,7 +22,8 @@ namespace Rcpp{ template