Skip to content

Commit 58d7a37

Browse files
committed
Don't cast LOGICAL() to int*
If the returned pointer type ever changes, the absence of the cast will give us a compiler warning due to the value being implicitly cast to an incompatible pointer type. An explicit cast, on the other hand, tells the compiler to silence the warning and do as written.
1 parent 32dfd8d commit 58d7a37

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/assign.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1207,7 +1207,7 @@ void writeNA(SEXP v, const int from, const int n, const bool listNA)
12071207
memset(RAW(v)+from, 0, n*sizeof(Rbyte));
12081208
break;
12091209
case LGLSXP: {
1210-
int *vd = (int *)LOGICAL(v);
1210+
int *vd = LOGICAL(v);
12111211
for (int i=from; i<=to; ++i) vd[i] = NA_LOGICAL;
12121212
} break;
12131213
case INTSXP: {

src/negate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ void negateByRef(SEXP x) {
55
error("not logical or integer vector"); // # nocov
66
}
77
const int n = length(x);
8-
int *ansd = (int *)LOGICAL(x);
8+
int *ansd = LOGICAL(x);
99
for(int i=0; i<n; ++i) {
1010
ansd[i] ^= (ansd[i] != NA_LOGICAL); // invert true/false but leave NA alone
1111
}

0 commit comments

Comments
 (0)