Skip to content

Commit 39669cb

Browse files
authored
Merge pull request #1240 from RcppCore/feature/clang_conversion_warnings
Address clang conversion warnings
2 parents 50a9585 + a15398c commit 39669cb

File tree

7 files changed

+40
-40
lines changed

7 files changed

+40
-40
lines changed

.github/workflows/ci.yaml

+11-11
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ jobs:
5656
- name: Check
5757
run: docker run --rm -i -v ${PWD}:/mnt -w /mnt -e CI=true ${{ matrix.cntr }} ${{ matrix.r }} CMD check --no-vignettes --no-manual Rcpp_*.tar.gz
5858

59-
covr:
60-
runs-on: ubuntu-latest
61-
steps:
62-
- name: Checkout Project
63-
uses: actions/checkout@v3
64-
65-
- name: Container
66-
run: docker pull rcpp/ci
67-
68-
- name: Coverage
69-
run: docker run --rm -i -v ${PWD}:/mnt -w /mnt -e CODECOV_TOKEN=${{secrets.CODECOV_TOKEN }} rcpp/ci r -l covr -e 'codecov()'
59+
#covr:
60+
# runs-on: ubuntu-latest
61+
# steps:
62+
# - name: Checkout Project
63+
# uses: actions/checkout@v3
64+
#
65+
# - name: Container
66+
# run: docker pull rcpp/ci
67+
#
68+
# - name: Coverage
69+
# run: docker run --rm -i -v ${PWD}:/mnt -w /mnt -e CODECOV_TOKEN=${{secrets.CODECOV_TOKEN }} rcpp/ci r -l covr -e 'codecov()'

ChangeLog

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
2023-01-08 Dirk Eddelbuettel <[email protected]>
2+
3+
* inst/include/Rcpp/String.h: Address clang++-14 conversion warning
4+
* inst/include/Rcpp/sugar/functions/mean.h: Idem
5+
* inst/include/Rcpp/vector/Vector.h: Idem
6+
* src/attributes.cpp: Idem
7+
* src/date.cpp: Idem
8+
19
2022-12-29 Dirk Eddelbuettel <[email protected]>
210

311
* .github/workflows/docker.yaml (jobs): Update several actions

inst/include/Rcpp/String.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// String.h: Rcpp R/C++ interface class library -- single string
33
//
44
// Copyright (C) 2012 - 2020 Dirk Eddelbuettel and Romain Francois
5-
// Copyright (C) 2021 Dirk Eddelbuettel, Romain Francois and Iñaki Ucar
5+
// Copyright (C) 2021 - 2023 Dirk Eddelbuettel, Romain Francois and Iñaki Ucar
66
//
77
// This file is part of Rcpp.
88
//
@@ -550,7 +550,7 @@ namespace Rcpp {
550550
#else
551551
if (buffer.find('\0') != std::string::npos)
552552
throw embedded_nul_in_string();
553-
return Rf_mkCharLenCE(buffer.c_str(), buffer.size(), enc);
553+
return Rf_mkCharLenCE(buffer.c_str(), static_cast<int>(buffer.size()), enc);
554554
#endif
555555
}
556556

inst/include/Rcpp/sugar/functions/mean.h

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*-
2-
//
31
// mean.h: Rcpp R/C++ interface class library -- mean
42
//
5-
// Copyright (C) 2011 - 2015 Dirk Eddelbuettel and Romain Francois
3+
// Copyright (C) 2011 - 2023 Dirk Eddelbuettel and Romain Francois
64
//
75
// This file is part of Rcpp.
86
//
@@ -80,8 +78,8 @@ class Mean<CPLXSXP,NA,T> : public Lazy<Rcomplex, Mean<CPLXSXP,NA,T> > {
8078
si += ti/n;
8179
}
8280
Rcomplex z;
83-
z.r = s;
84-
z.i = si;
81+
z.r = static_cast<double>(s);
82+
z.i = static_cast<double>(si);
8583
return z;
8684
}
8785
private:
@@ -158,5 +156,3 @@ inline sugar::Mean<LGLSXP,NA,T> mean(const VectorBase<LGLSXP,NA,T>& t) {
158156

159157
} // Rcpp
160158
#endif
161-
162-

inst/include/Rcpp/vector/Vector.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
//
21
// Vector.h: Rcpp R/C++ interface class library -- vectors
32
//
4-
// Copyright (C) 2010 - 2022 Dirk Eddelbuettel and Romain Francois
3+
// Copyright (C) 2010 - 2023 Dirk Eddelbuettel and Romain Francois
54
//
65
// This file is part of Rcpp.
76
//
@@ -332,7 +331,7 @@ class Vector :
332331
}
333332

334333
inline iterator begin() { return cache.get() ; }
335-
inline iterator end() { return cache.get() + size() ; }
334+
inline iterator end() { return cache.get() + static_cast<int>(size()) ; }
336335
inline const_iterator begin() const{ return cache.get_const() ; }
337336
inline const_iterator end() const{ return cache.get_const() + size() ; }
338337
inline const_iterator cbegin() const{ return cache.get_const() ; }

src/attributes.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
//
21
// attributes.cpp: Rcpp R/C++ interface class library -- Rcpp attributes
32
//
43
// Copyright (C) 2012 - 2020 JJ Allaire, Dirk Eddelbuettel and Romain Francois
5-
// Copyright (C) 2021 - 2022 JJ Allaire, Dirk Eddelbuettel, Romain Francois, Iñaki Ucar and Travers Ching
4+
// Copyright (C) 2021 - 2023 JJ Allaire, Dirk Eddelbuettel, Romain Francois, Iñaki Ucar and Travers Ching
65
//
76
// This file is part of Rcpp.
87
//
@@ -1622,7 +1621,7 @@ namespace attributes {
16221621
// Look for the signature termination ({ or ; not inside quotes)
16231622
// on this line and then subsequent lines if necessary
16241623
std::string signature;
1625-
for (int i = lineNumber; i<lines_.size(); i++) {
1624+
for (size_t i = lineNumber; i<lines_.size(); i++) {
16261625
std::string line;
16271626
line = lines_[i];
16281627
bool insideQuotes = false;

src/date.cpp

+12-14
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
2-
//
31
// Date.cpp: Rcpp R/C++ interface class library -- Date type
42
//
5-
// Copyright (C) 2010 - 2019 Dirk Eddelbuettel and Romain Francois
3+
// Copyright (C) 2010 - 2023 Dirk Eddelbuettel and Romain Francois
64
//
75
// The mktime00() as well as the gmtime_() replacement function are
86
// Copyright (C) 2000 - 2010 The R Development Core Team.
@@ -85,10 +83,10 @@ namespace Rcpp {
8583
/* safety check for unbounded loops */
8684
if (year0 > 3000) {
8785
excess = (int)(year0/2000) - 1; // #nocov start
88-
year0 -= excess * 2000;
86+
year0 -= (int)(excess * 2000);
8987
} else if (year0 < 0) {
9088
excess = -1 - (int)(-year0/2000);
91-
year0 -= excess * 2000; // #nocov end
89+
year0 -= (int)(excess * 2000); // #nocov end
9290
}
9391

9492
for(i = 0; i < tm.tm_mon; i++) day += days_in_month[i];
@@ -450,7 +448,7 @@ struct tzhead {
450448
** Normalize logic courtesy Paul Eggert.
451449
*/
452450

453-
static int increment_overflow(int *const ip, int j) {
451+
static int increment_overflow(int *const ip, int j) {
454452
int const i = *ip;
455453

456454
/*
@@ -460,7 +458,7 @@ struct tzhead {
460458
** or if j < INT_MIN - i; given i < 0, INT_MIN - i cannot overflow.
461459
*/
462460
if ((i >= 0) ? (j > INT_MAX - i) : (j < INT_MIN - i))
463-
return TRUE; // #nocov
461+
return TRUE; // #nocov
464462
*ip += j;
465463
return FALSE;
466464
}
@@ -476,10 +474,10 @@ struct tzhead {
476474
: *tp <= time_t_max - j))
477475
return TRUE;
478476
*tp += j;
479-
return FALSE;
477+
return FALSE;
480478
}
481479

482-
static int_fast32_t detzcode(const char *const codep) {
480+
static int_fast32_t detzcode(const char *const codep) {
483481
int_fast32_t result = (codep[0] & 0x80) ? -1 : 0;
484482
for (int i = 0; i < 4; ++i)
485483
result = (result << 8) | (codep[i] & 0xff);
@@ -628,7 +626,7 @@ struct tzhead {
628626
return strp;
629627
}
630628

631-
// this routine modified / simplified / reduced in 2010
629+
// this routine modified / simplified / reduced in 2010
632630
static int tzload(const char * name, struct state * const sp, const int doextend) {
633631
const char * p;
634632
int i;
@@ -701,7 +699,7 @@ struct tzhead {
701699
}
702700

703701
}
704-
nread = read(fid, u.buf, sizeof u.buf);
702+
nread = (int)read(fid, u.buf, sizeof u.buf);
705703
if (close(fid) < 0 || nread <= 0)
706704
return -1;
707705
for (stored = 4; stored <= 8; stored *= 2) {
@@ -851,7 +849,7 @@ struct tzhead {
851849
while (i < ts.timecnt &&
852850
sp->timecnt < TZ_MAX_TIMES) {
853851
sp->ats[sp->timecnt] = ts.ats[i];
854-
sp->types[sp->timecnt] = sp->typecnt + ts.types[i];
852+
sp->types[sp->timecnt] = (unsigned char)sp->typecnt + ts.types[i];
855853
++sp->timecnt;
856854
++i;
857855
}
@@ -1217,7 +1215,7 @@ struct tzhead {
12171215
&sp->chars[bp->tt_abbrind]) == 0;
12181216
}
12191217
return result;
1220-
} // #nocov end
1218+
} // #nocov end
12211219

12221220
static int leaps_thru_end_of(const int y) {
12231221
return (y >= 0) ? (y / 4 - y / 100 + y / 400) :
@@ -1316,7 +1314,7 @@ struct tzhead {
13161314
}
13171315
// Previously we returned 'year + base', so keep behaviour
13181316
// It seems like R now returns just 'year - 1900' (as libc does)
1319-
// But better for continuity to do as before
1317+
// But better for continuity to do as before
13201318
tmp->tm_year = y + TM_YEAR_BASE;
13211319
if (increment_overflow(&tmp->tm_year, -TM_YEAR_BASE))
13221320
return NULL; // #nocov

0 commit comments

Comments
 (0)