File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
inst/include/Rcpp/sugar/tools Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change 112013-12-20 Kevin Ushey <kevinushey@gmail.com>
22
3+ * inst/include/Rcpp/sugar/tools/mapcompare.h: Use a union for
4+ type punning, to avoid compiler warning on aliasing. Also
5+ switch to uint64_t to enforce 64bit comparison.
36 * inst/include/Rcpp/RObject.h: Add missing *this return for
47 RObject_impl::operator=
58
Original file line number Diff line number Diff line change 2525namespace Rcpp {
2626namespace sugar {
2727
28- static unsigned long const R_UNSIGNED_LONG_NA_REAL = *(unsigned long *)(&NA_REAL);
29- static unsigned long const R_UNSIGNED_LONG_NAN_REAL = *(unsigned long *)(&R_NaN);
28+ union DoublePunner {
29+ double d;
30+ uint64_t p;
31+ };
32+
33+ static const DoublePunner NA_REAL_PUN = { NA_REAL };
34+ static const DoublePunner NAN_REAL_PUN = { R_NaN };
3035
3136inline bool Rcpp_IsNA (double x) {
32- return *reinterpret_cast <unsigned long *>(&x) == R_UNSIGNED_LONG_NA_REAL;
37+ DoublePunner xp = { x };
38+ return xp.p == NA_REAL_PUN.p ;
3339}
3440
3541inline bool Rcpp_IsNaN (double x) {
36- return *reinterpret_cast <unsigned long *>(&x) == R_UNSIGNED_LONG_NAN_REAL;
42+ DoublePunner xp = { x };
43+ return xp.p == NAN_REAL_PUN.p ;
3744}
3845
3946inline int StrCmp (SEXP x, SEXP y) {
You can’t perform that action at this time.
0 commit comments