diff --git a/src/main/identical.c b/src/main/identical.c index ad99f83d9e5..a126fcaec32 100644 --- a/src/main/identical.c +++ b/src/main/identical.c @@ -230,19 +230,19 @@ R_compute_identical(SEXP x, SEXP y, int flags) case LGLSXP: if (XLENGTH(x) != XLENGTH(y)) return FALSE; /* Use memcmp (which is ISO C90) to speed up the comparison */ - return memcmp((void *)LOGICAL(x), (void *)LOGICAL(y), + return memcmp((const void *)LOGICAL_RO(x), (const void *)LOGICAL_RO(y), xlength(x) * sizeof(int)) == 0 ? TRUE : FALSE; case INTSXP: if (XLENGTH(x) != XLENGTH(y)) return FALSE; /* Use memcmp (which is ISO C90) to speed up the comparison */ - return memcmp((void *)INTEGER(x), (void *)INTEGER(y), + return memcmp((const void *)INTEGER_RO(x), (const void *)INTEGER_RO(y), xlength(x) * sizeof(int)) == 0 ? TRUE : FALSE; case REALSXP: { R_xlen_t n = XLENGTH(x); if(n != XLENGTH(y)) return FALSE; else { - double *xp = REAL(x), *yp = REAL(y); + const double *xp = REAL_RO(x), *yp = REAL_RO(y); int ne_strict = NUM_EQ | (SINGLE_NA << 1); for(R_xlen_t i = 0; i < n; i++) if(neWithNaN(xp[i], yp[i], ne_strict)) return FALSE; @@ -254,7 +254,7 @@ R_compute_identical(SEXP x, SEXP y, int flags) R_xlen_t n = XLENGTH(x); if(n != XLENGTH(y)) return FALSE; else { - Rcomplex *xp = COMPLEX(x), *yp = COMPLEX(y); + const Rcomplex *xp = COMPLEX_RO(x), *yp = COMPLEX_RO(y); int ne_strict = NUM_EQ | (SINGLE_NA << 1); for(R_xlen_t i = 0; i < n; i++) if(neWithNaN(xp[i].r, yp[i].r, ne_strict) || @@ -345,7 +345,7 @@ R_compute_identical(SEXP x, SEXP y, int flags) case RAWSXP: if (XLENGTH(x) != XLENGTH(y)) return FALSE; /* Use memcmp (which is ISO C90) to speed up the comparison */ - return memcmp((void *)RAW(x), (void *)RAW(y), + return memcmp((const void *)RAW_RO(x), (const void *)RAW_RO(y), XLENGTH(x) * sizeof(Rbyte)) == 0 ? TRUE : FALSE; case PROMSXP: {