Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/werror.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

env:
_R_CHECK_FORCE_SUGGESTS_: "false"
RCPP_CXXFLAGS: "-Werror -Wall -Wextra"
RCPP_CXXFLAGS: "-Werror -Wall -Wextra -Wconversion"

jobs:
ci:
Expand Down
47 changes: 47 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,50 @@
2026-09-05 Iñaki Ucar <iucar@fedoraproject.org>

* .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<T> 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 <edd@debian.org>

* DESCRIPTION (Version, Date): Roll micro version and date
Expand Down
6 changes: 4 additions & 2 deletions inst/include/Rcpp/DataFrame.h
Original file line number Diff line number Diff line change
@@ -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.
//
Expand Down Expand Up @@ -46,7 +47,8 @@ namespace Rcpp{
set__(other) ;
}

template <typename T>
template <typename T,
typename std::enable_if<std::is_convertible<T, SEXP>::value, int>::type = 0>
DataFrame_Impl( const T& obj ) ;

DataFrame_Impl& operator=( DataFrame_Impl& other){
Expand Down
5 changes: 3 additions & 2 deletions inst/include/Rcpp/Language.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//
Expand Down Expand Up @@ -189,7 +190,7 @@ namespace Rcpp{
class unary_call : public std::function<RESULT_TYPE(T)> {
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 ){
Expand All @@ -206,7 +207,7 @@ namespace Rcpp{
class binary_call : public std::function<RESULT_TYPE(T1,T2)> {
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 ){
Expand Down
6 changes: 4 additions & 2 deletions inst/include/Rcpp/api/meat/DataFrame.h
Original file line number Diff line number Diff line change
@@ -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.
//
Expand All @@ -21,7 +22,8 @@
namespace Rcpp{

template <template <class> class StoragePolicy>
template <class T>
template <class T,
typename std::enable_if<std::is_convertible<T, SEXP>::value, int>::type>
DataFrame_Impl<StoragePolicy>::DataFrame_Impl( const T& obj){
set__(Shield<SEXP>(wrap(obj)));
}
Expand Down
24 changes: 12 additions & 12 deletions inst/include/Rcpp/internal/wrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ namespace Rcpp {
template <typename T>
inline SEXP wrap_dispatch_matrix_logical(const T& object, ::Rcpp::traits::true_type) {
int nr = object.nrow(), nc = object.ncol();
Shield<SEXP> res(Rf_allocVector(LGLSXP, nr * nc));
Shield<SEXP> res(Rf_allocVector(LGLSXP, static_cast<R_xlen_t>(nr) * nc));
int k=0;
int* p = LOGICAL(res);
for (int j=0; j<nc; j++)
Expand All @@ -581,7 +581,7 @@ namespace Rcpp {
inline SEXP wrap_dispatch_matrix_primitive(const T& object) {
const int RTYPE = ::Rcpp::traits::r_sexptype_traits<STORAGE>::rtype;
int nr = object.nrow(), nc = object.ncol();
Shield<SEXP> res(Rf_allocVector(RTYPE, nr*nc));
Shield<SEXP> res(Rf_allocVector(RTYPE, static_cast<R_xlen_t>(nr)*nc));

int k=0;
STORAGE* p = r_vector_start< RTYPE>(res);
Expand All @@ -603,7 +603,7 @@ namespace Rcpp {
template <typename T>
inline SEXP wrap_dispatch_matrix_not_logical(const T& object, ::Rcpp::traits::r_type_string_tag) {
int nr = object.nrow(), nc = object.ncol();
Shield<SEXP> res(Rf_allocVector(STRSXP, nr*nc));
Shield<SEXP> res(Rf_allocVector(STRSXP, static_cast<R_xlen_t>(nr)*nc));

int k=0;
for (int j=0; j<nc; j++)
Expand All @@ -619,7 +619,7 @@ namespace Rcpp {
template <typename T>
inline SEXP wrap_dispatch_matrix_not_logical(const T& object, ::Rcpp::traits::r_type_generic_tag) {
int nr = object.nrow(), nc = object.ncol();
Shield<SEXP> res(Rf_allocVector(VECSXP, nr*nc));
Shield<SEXP> res(Rf_allocVector(VECSXP, static_cast<R_xlen_t>(nr)*nc));

int k=0;
for (int j=0; j<nc; j++)
Expand Down Expand Up @@ -665,12 +665,12 @@ namespace Rcpp {

template <typename T, typename elem_type>
inline SEXP wrap_dispatch_importer__impl__prim(const T& object, ::Rcpp::traits::false_type) {
int size = object.size();
R_xlen_t size = object.size();
const int RTYPE = ::Rcpp::traits::r_sexptype_traits<elem_type>::rtype;
Shield<SEXP> x(Rf_allocVector(RTYPE, size));
typedef typename ::Rcpp::traits::storage_type<RTYPE>::type CTYPE;
CTYPE* start = r_vector_start<RTYPE>(x);
for (int i=0; i<size; i++) {
for (R_xlen_t i=0; i<size; i++) {
start[i] = object.get(i);
}
return x;
Expand All @@ -679,12 +679,12 @@ namespace Rcpp {

template <typename T, typename elem_type>
inline SEXP wrap_dispatch_importer__impl__prim(const T& object, ::Rcpp::traits::true_type) {
int size = object.size();
R_xlen_t size = object.size();
const int RTYPE = ::Rcpp::traits::r_sexptype_traits<elem_type>::rtype;
Shield<SEXP> x(Rf_allocVector(RTYPE, size));
typedef typename ::Rcpp::traits::storage_type<RTYPE>::type CTYPE;
CTYPE* start = r_vector_start<RTYPE>(x);
for (int i=0; i<size; i++) {
for (R_xlen_t i=0; i<size; i++) {
start[i] = caster<elem_type,CTYPE>(object.get(i));
}
return x;
Expand All @@ -698,19 +698,19 @@ namespace Rcpp {

template <typename T, typename elem_type>
inline SEXP wrap_dispatch_importer__impl(const T& object, ::Rcpp::traits::r_type_string_tag) {
int size = object.size();
R_xlen_t size = object.size();
Shield<SEXP> x(Rf_allocVector(STRSXP, size));
for (int i=0; i<size; i++) {
for (R_xlen_t i=0; i<size; i++) {
SET_STRING_ELT(x, i, make_charsexp(object.get(i)));
}
return x;
}

template <typename T, typename elem_type>
inline SEXP wrap_dispatch_importer__impl(const T& object, ::Rcpp::traits::r_type_generic_tag) {
int size = object.size();
R_xlen_t size = object.size();
Shield<SEXP> x(Rf_allocVector(VECSXP, size));
for (int i=0; i<size; i++) {
for (R_xlen_t i=0; i<size; i++) {
SET_VECTOR_ELT(x, i, object.wrap(i));
}
return x;
Expand Down
7 changes: 4 additions & 3 deletions inst/include/Rcpp/macros/interface.h
Original file line number Diff line number Diff line change
@@ -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.
//
Expand Down Expand Up @@ -31,7 +32,7 @@ __CLASS__& operator=(const __CLASS__& rhs) { \
return Storage::copy__(rhs) ; \
} \
template <typename Proxy> \
__CLASS__( const GenericProxy<Proxy>& proxy ){ \
explicit __CLASS__( const GenericProxy<Proxy>& proxy ){ \
Storage::set__( proxy.get() ) ; \
}

Expand All @@ -42,7 +43,7 @@ __CLASS__& operator=(const __CLASS__& rhs) { \
return Storage::copy__(rhs) ; \
} \
template <typename Proxy> \
__CLASS__( const GenericProxy<Proxy>& proxy ){ \
explicit __CLASS__( const GenericProxy<Proxy>& proxy ){ \
Storage::set__( proxy.get() ) ; \
}

Expand Down
Loading