Skip to content

Commit 5207973

Browse files
authored
Additional switch to size_t (or R_xlen_t) to avoid conversion warnings from clang++-17 (#1309)
* Another 'clang++-17 -Wconversion -Wsign-conversion' * More 'clang++-17 -Wconversion -Wno-sign-conversion' changes * Revert a change
1 parent b694118 commit 5207973

File tree

7 files changed

+27
-21
lines changed

7 files changed

+27
-21
lines changed

ChangeLog

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
2024-06-02 Dirk Eddelbuettel <[email protected]>
2+
3+
* inst/include/Rcpp/internal/export.h: More R_xlen_t switching
4+
* inst/include/Rcpp/vector/SubMatrix.h: Idem
5+
* inst/include/Rcpp/vector/Vector.h: Idem
6+
7+
2024-06-01 Dirk Eddelbuettel <[email protected]>
8+
9+
* inst/include/Rcpp/internal/Proxy_Iterator.h (Proxy_Iterator):
10+
Switch to R_xlen_t ('clang++-17 -Wconversion -Wno-sign-conversion')
11+
* inst/include/Rcpp/DataFrame.h: Idem
12+
* inst/include/Rcpp/Vector.h: Idem
13+
114
2024-05-28 Dirk Eddelbuettel <[email protected]>
215

316
* DESCRIPTION (Version, Date): Roll micro version

inst/include/Rcpp/DataFrame.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ namespace Rcpp{
137137
}
138138

139139
void set_type_after_push(){
140-
int max_rows = 0;
140+
R_xlen_t max_rows = 0;
141141
bool invalid_column_size = false;
142142
List::iterator it;
143143
// Get the maximum number of rows

inst/include/Rcpp/Vector.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
2-
//
1+
32
// Vector.h: Rcpp R/C++ interface class library -- vectors
43
//
54
// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois

inst/include/Rcpp/internal/Proxy_Iterator.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
2-
/* :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: */
3-
//
1+
42
// Proxy_Iterator.h: Rcpp R/C++ interface class library --
53
//
64
// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois
@@ -31,7 +29,7 @@ class Proxy_Iterator {
3129
public:
3230
typedef PROXY& reference ;
3331
typedef PROXY* pointer ;
34-
typedef int difference_type ;
32+
typedef R_xlen_t difference_type ;
3533
typedef PROXY value_type;
3634
typedef std::random_access_iterator_tag iterator_category ;
3735

@@ -122,4 +120,3 @@ class Proxy_Iterator {
122120
}
123121

124122
#endif
125-

inst/include/Rcpp/internal/export.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2-
/* :tabSize=4:indentSize=4:noTabs=false:folding=explicit:collapseFolds=1: */
3-
//
1+
42
// export.h: Rcpp R/C++ interface class library --
53
//
64
// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois

inst/include/Rcpp/vector/SubMatrix.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
2-
//
1+
32
// SubMatrix.h: Rcpp R/C++ interface class library -- sub matrices
43
//
54
// Copyright (C) 2010 - 2013 Dirk Eddelbuettel and Romain Francois
@@ -40,8 +39,8 @@ class SubMatrix : public Rcpp::MatrixBase< RTYPE, true, SubMatrix<RTYPE> > {
4039
{}
4140

4241
inline R_xlen_t size() const { return ((R_xlen_t)ncol()) * nrow() ; }
43-
inline int ncol() const { return nc ; }
44-
inline int nrow() const { return nr ; }
42+
inline R_xlen_t ncol() const { return nc ; }
43+
inline R_xlen_t nrow() const { return nr ; }
4544

4645
inline Proxy operator()(int i, int j) const {
4746
return iter[ i + j*m_nr ] ;
@@ -52,16 +51,16 @@ class SubMatrix : public Rcpp::MatrixBase< RTYPE, true, SubMatrix<RTYPE> > {
5251
private:
5352
MATRIX& m ;
5453
vec_iterator iter ;
55-
int m_nr, nc, nr ;
54+
R_xlen_t m_nr, nc, nr ;
5655
} ;
5756

5857
template <int RTYPE, template <class> class StoragePolicy >
59-
Matrix<RTYPE,StoragePolicy>::Matrix( const SubMatrix<RTYPE>& sub ) : VECTOR( Rf_allocMatrix( RTYPE, sub.nrow(), sub.ncol() )), nrows(sub.nrow()) {
60-
int nc = sub.ncol() ;
58+
Matrix<RTYPE,StoragePolicy>::Matrix( const SubMatrix<RTYPE>& sub ) : VECTOR( Rf_allocMatrix( RTYPE, (int)sub.nrow(), (int)sub.ncol() )), nrows((int)sub.nrow()) {
59+
R_xlen_t nc = sub.ncol() ;
6160
iterator start = VECTOR::begin() ;
6261
iterator rhs_it ;
63-
for( int j=0; j<nc; j++){
64-
rhs_it = sub.column_iterator(j) ;
62+
for( R_xlen_t j=0; j<nc; j++){
63+
rhs_it = sub.column_iterator((int)j) ;
6564
for( int i=0; i<nrows; i++, ++start){
6665
*start = rhs_it[i] ;
6766
}

inst/include/Rcpp/vector/Vector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ class Vector :
593593
return false ;
594594
}
595595

596-
int findName(const std::string& name) const {
596+
R_xlen_t findName(const std::string& name) const {
597597
SEXP names = RCPP_GET_NAMES(Storage::get__());
598598
if (Rf_isNull(names)) stop("'names' attribute is null");
599599
R_xlen_t n = Rf_xlength(names);

0 commit comments

Comments
 (0)