Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure format strings pass check in R-devel/Windows #345

Merged
merged 3 commits into from
Dec 1, 2023
Merged
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
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# cpp11 (development version)

* Internal changes requested by CRAN to fix invalid format string tokens
(@paleolimbot, #345).

# cpp11 0.4.6

* R >=3.5.0 is now required to use cpp11. This is in line with (and even goes
Expand Down
4 changes: 3 additions & 1 deletion inst/include/cpp11/protect.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,9 @@ static struct {
void print() {
static SEXP list = get_preserve_list();
for (SEXP cell = list; cell != R_NilValue; cell = CDR(cell)) {
REprintf("%x CAR: %x CDR: %x TAG: %x\n", cell, CAR(cell), CDR(cell), TAG(cell));
REprintf("%p CAR: %p CDR: %p TAG: %p\n", reinterpret_cast<void*>(cell),
reinterpret_cast<void*>(CAR(cell)), reinterpret_cast<void*>(CDR(cell)),
reinterpret_cast<void*>(TAG(cell)));
}
REprintf("---\n");
}
Expand Down
11 changes: 6 additions & 5 deletions inst/include/cpp11/sexp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ class sexp {
sexp() = default;

sexp(SEXP data) : data_(data), preserve_token_(preserved.insert(data_)) {
// REprintf("created %x %x : %i\n", data_, preserve_token_, protect_head_size());
// REprintf("created %p %p\n", reinterpret_cast<void*>(data_),
// reinterpret_cast<void*>(preserve_token_));
}

sexp(const sexp& rhs) {
data_ = rhs.data_;
preserve_token_ = preserved.insert(data_);
// REprintf("copied %x new protect %x : %i\n", rhs.data_, preserve_token_,
// protect_head_size());
// REprintf("copied %p new protect %p\n", reinterpret_cast<void*>(rhs.data_),
// reinterpret_cast<void*>(preserve_token_));
}

sexp(sexp&& rhs) {
Expand All @@ -37,15 +38,15 @@ class sexp {
rhs.data_ = R_NilValue;
rhs.preserve_token_ = R_NilValue;

// REprintf("moved %x : %i\n", rhs.data_, protect_head_size());
// REprintf("moved %p\n", reinterpret_cast<void*>(rhs.data_));
}

sexp& operator=(const sexp& rhs) {
preserved.release(preserve_token_);

data_ = rhs.data_;
preserve_token_ = preserved.insert(data_);
// REprintf("assigned %x : %i\n", rhs.data_, protect_head_size());
// REprintf("assigned %p\n", reinterpret_cast<void*>(rhs.data_));
return *this;
}

Expand Down
Loading