Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional switch to size_t (or R_xlen_t) to avoid conversion warnings from clang++-17 #1309

Merged
merged 3 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
13 changes: 13 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
2024-06-02 Dirk Eddelbuettel <edd@debian.org>

* inst/include/Rcpp/internal/export.h: More R_xlen_t switching
* inst/include/Rcpp/vector/SubMatrix.h: Idem
* inst/include/Rcpp/vector/Vector.h: Idem

2024-06-01 Dirk Eddelbuettel <edd@debian.org>

* inst/include/Rcpp/internal/Proxy_Iterator.h (Proxy_Iterator):
Switch to R_xlen_t ('clang++-17 -Wconversion -Wno-sign-conversion')
* inst/include/Rcpp/DataFrame.h: Idem
* inst/include/Rcpp/Vector.h: Idem

2024-05-28 Dirk Eddelbuettel <edd@debian.org>

* DESCRIPTION (Version, Date): Roll micro version
Expand Down
2 changes: 1 addition & 1 deletion inst/include/Rcpp/DataFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ namespace Rcpp{
}

void set_type_after_push(){
int max_rows = 0;
R_xlen_t max_rows = 0;
bool invalid_column_size = false;
List::iterator it;
// Get the maximum number of rows
Expand Down
3 changes: 1 addition & 2 deletions inst/include/Rcpp/Vector.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
//

// Vector.h: Rcpp R/C++ interface class library -- vectors
//
// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois
Expand Down
7 changes: 2 additions & 5 deletions inst/include/Rcpp/internal/Proxy_Iterator.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
/* :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: */
//

// Proxy_Iterator.h: Rcpp R/C++ interface class library --
//
// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois
Expand Down Expand Up @@ -31,7 +29,7 @@ class Proxy_Iterator {
public:
typedef PROXY& reference ;
typedef PROXY* pointer ;
typedef int difference_type ;
typedef R_xlen_t difference_type ;
typedef PROXY value_type;
typedef std::random_access_iterator_tag iterator_category ;

Expand Down Expand Up @@ -122,4 +120,3 @@ class Proxy_Iterator {
}

#endif

4 changes: 1 addition & 3 deletions inst/include/Rcpp/internal/export.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
/* :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: */
//

// export.h: Rcpp R/C++ interface class library --
//
// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois
Expand Down
17 changes: 8 additions & 9 deletions inst/include/Rcpp/vector/SubMatrix.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
//

// SubMatrix.h: Rcpp R/C++ interface class library -- sub matrices
//
// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois
Expand Down Expand Up @@ -40,8 +39,8 @@ class SubMatrix : public Rcpp::MatrixBase< RTYPE, true, SubMatrix<RTYPE> > {
{}

inline R_xlen_t size() const { return ((R_xlen_t)ncol()) * nrow() ; }
inline int ncol() const { return nc ; }
inline int nrow() const { return nr ; }
inline R_xlen_t ncol() const { return nc ; }
inline R_xlen_t nrow() const { return nr ; }

inline Proxy operator()(int i, int j) const {
return iter[ i + j*m_nr ] ;
Expand All @@ -52,16 +51,16 @@ class SubMatrix : public Rcpp::MatrixBase< RTYPE, true, SubMatrix<RTYPE> > {
private:
MATRIX& m ;
vec_iterator iter ;
int m_nr, nc, nr ;
R_xlen_t m_nr, nc, nr ;
} ;

template <int RTYPE, template <class> class StoragePolicy >
Matrix<RTYPE,StoragePolicy>::Matrix( const SubMatrix<RTYPE>& sub ) : VECTOR( Rf_allocMatrix( RTYPE, sub.nrow(), sub.ncol() )), nrows(sub.nrow()) {
int nc = sub.ncol() ;
Matrix<RTYPE,StoragePolicy>::Matrix( const SubMatrix<RTYPE>& sub ) : VECTOR( Rf_allocMatrix( RTYPE, (int)sub.nrow(), (int)sub.ncol() )), nrows((int)sub.nrow()) {
R_xlen_t nc = sub.ncol() ;
iterator start = VECTOR::begin() ;
iterator rhs_it ;
for( int j=0; j<nc; j++){
rhs_it = sub.column_iterator(j) ;
for( R_xlen_t j=0; j<nc; j++){
rhs_it = sub.column_iterator((int)j) ;
for( int i=0; i<nrows; i++, ++start){
*start = rhs_it[i] ;
}
Expand Down
2 changes: 1 addition & 1 deletion inst/include/Rcpp/vector/Vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ class Vector :
return false ;
}

int findName(const std::string& name) const {
R_xlen_t findName(const std::string& name) const {
SEXP names = RCPP_GET_NAMES(Storage::get__());
if (Rf_isNull(names)) stop("'names' attribute is null");
R_xlen_t n = Rf_xlength(names);
Expand Down
Loading