Skip to content

Commit

Permalink
use warning instead of stop
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinushey committed Jun 18, 2024
1 parent 69cb4dd commit bc529e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions inst/include/Rcpp/vector/traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace traits{
void check_index(R_xlen_t i) const {
#ifndef RCPP_NO_BOUNDS_CHECK
if (i >= size) {
stop("subscript out of bounds (index %s >= vector size %s)", i, size);
warning("subscript out of bounds (index %s >= vector size %s)", i, size);
}
#endif
}
Expand Down Expand Up @@ -94,7 +94,7 @@ namespace traits{
void check_index(R_xlen_t i) const {
#ifndef RCPP_NO_BOUNDS_CHECK
if (i >= p->size()) {
stop("subscript out of bounds (index %s >= vector size %s)", i, p->size());
warning("subscript out of bounds (index %s >= vector size %s)", i, p->size());
}
#endif
}
Expand Down
9 changes: 5 additions & 4 deletions inst/tinytest/test_vector.R
Original file line number Diff line number Diff line change
Expand Up @@ -696,8 +696,9 @@ expect_true( !CharacterVector_test_equality("foo", "bar") )
expect_true( !CharacterVector_test_equality_crosspolicy("foo", "bar") )

# https://github.com/RcppCore/Rcpp/issues/1308
expect_error(NumericVector_test_out_of_bounds_read(numeric(0), 0))
expect_error(NumericVector_test_out_of_bounds_read(numeric(1), 1))
expect_error(CharacterVector_test_out_of_bounds_read(character(0), 0))
expect_error(CharacterVector_test_out_of_bounds_read(character(1), 1))
# tests disabled since these could trigger UBSAN warnings / crashes
#expect_warning(NumericVector_test_out_of_bounds_read(numeric(0), 0))
#expect_warning(NumericVector_test_out_of_bounds_read(numeric(1), 1))
#expect_warning(CharacterVector_test_out_of_bounds_read(character(0), 0))
#expect_warning(CharacterVector_test_out_of_bounds_read(character(1), 1))

0 comments on commit bc529e0

Please sign in to comment.