Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2026-08-02 Kevin Ushey <kevinushey@gmail.com>

* inst/include/Rcpp/api/meat/StretchyList.h: Protect the new cell
from collection during Rf_install() in named push_back() (#1489)
* inst/tinytest/cpp/misc.cpp: Add regression test
* inst/tinytest/test_misc.R: Idem

2026-07-24 Dirk Eddelbuettel <edd@debian.org>

* DESCRIPTION (Version, Date): Roll micro version and date
Expand Down
2 changes: 1 addition & 1 deletion inst/include/Rcpp/api/meat/StretchyList.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ namespace Rcpp{
template< typename T>
StretchyList_Impl<StoragePolicy>& StretchyList_Impl<StoragePolicy>::push_back__impl( const T& obj, traits::true_type ){
Shield<SEXP> s( wrap(obj.object) ) ;
SEXP tmp = Rf_cons( s, R_NilValue );
Symbol tag = obj.name ;
SEXP tmp = Rf_cons( s, R_NilValue );
SET_TAG(tmp, tag) ;
SEXP self = Storage::get__() ;
SETCDR( CAR(self), tmp) ;
Expand Down
7 changes: 7 additions & 0 deletions inst/tinytest/cpp/misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@ StretchyList named_stretchy_list() {
return out;
}

// [[Rcpp::export]]
StretchyList named_stretchy_list_dynamic(std::string name) {
StretchyList out;
out.push_back( Named(name, 42) );
return out;
}

// [[Rcpp::export]]
void test_stop_variadic() {
stop( "%s %d", "foo", 3 );
Expand Down
11 changes: 11 additions & 0 deletions inst/tinytest/test_misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,17 @@ expect_equal(stretchy_list(), pairlist( "foo", 1L, 3.2 ))
# test.named_StretchyList <- function(){
expect_equal(named_stretchy_list(), pairlist( a = "foo", b = 1L, c = 3.2 ))

# test.named_StretchyList_gc <- function(){
## push_back() must keep the new cell protected across the Rf_install()
## needed for a not-yet-interned tag name (#1489)
name <- paste(sample(c(letters, LETTERS), 32, TRUE), collapse = "")
gctorture(TRUE)
result <- named_stretchy_list_dynamic(name)
gctorture(FALSE)
expected <- pairlist(42L)
names(expected) <- name
expect_equal(result, expected)

# test.stop.variadic <- function(){
m <- tryCatch( test_stop_variadic(), error = function(e){
conditionMessage(e)
Expand Down
Loading