Skip to content

Commit 21aca12

Browse files
committed
go back to using dataptr()
1 parent 950d8f5 commit 21aca12

File tree

2 files changed

+2
-19
lines changed

2 files changed

+2
-19
lines changed

ChangeLog

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
2026-03-26 Iñaki Ucar <iucar@fedoraproject.org>
22

3-
* inst/include/Rcpp/internal/r_vector.h: Return null start for empty vectors
4-
instead of an invalid pointer, which causes UB in e.g. std::copy
3+
* inst/include/Rcpp/internal/r_vector.h: Use dataptr() again to avoid an
4+
invalid pointer for empty vectors, which causes UB in e.g. std::copy
55
* inst/tinytest/test_vector.R: Add tests for std::copy
66
* inst/tinytest/cpp/Vector.cpp: Idem
77

inst/include/Rcpp/internal/r_vector.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,6 @@ typename Rcpp::traits::storage_type<RTYPE>::type* r_vector_start(SEXP x) {
3333
return reinterpret_cast<pointer>(dataptr(x));
3434
}
3535

36-
// add specializations to avoid use of dataptr
37-
#define RCPP_VECTOR_START_IMPL(__RTYPE__, __ACCESSOR__) \
38-
template <> \
39-
inline typename Rcpp::traits::storage_type<__RTYPE__>::type* r_vector_start<__RTYPE__>(SEXP x) { \
40-
if (Rf_xlength(x) == 0) \
41-
return NULL; \
42-
return __ACCESSOR__(x); \
43-
}
44-
45-
RCPP_VECTOR_START_IMPL(LGLSXP, LOGICAL);
46-
RCPP_VECTOR_START_IMPL(INTSXP, INTEGER);
47-
RCPP_VECTOR_START_IMPL(RAWSXP, RAW);
48-
RCPP_VECTOR_START_IMPL(CPLXSXP, COMPLEX);
49-
RCPP_VECTOR_START_IMPL(REALSXP, REAL);
50-
51-
#undef RCPP_VECTOR_START_IMPL
52-
5336
/**
5437
* The value 0 statically casted to the appropriate type for
5538
* the given SEXP type

0 commit comments

Comments
 (0)