Repository navigation
return *this from the free-getter, member-setter property() overload - #1520
Open
kevinushey wants to merge 1 commit into
Open
kevinushey wants to merge 1 commit into
kevinushey wants to merge 1 commit into
Conversation
eddelbuettel
approved these changes
Oct 29, 2026
eddelbuettel
left a comment
Member
There was a problem hiding this comment.
👍
Nice 'lines of tests and documentation' / 'lines of new code' ration too :)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1519.
The
class_<T>::property()overload taking a free-function getter (PROP (*)(Class*)) and a member-function setter fell off the end without returning*this. That is undefined behavior; with Apple clang it compiles to a trap, so any module using the overload aborts the R session as soon as it is loaded. See #1519 for the reprex.Changes:
inst/include/Rcpp/module/Module_Add_Property.h: add the missingreturn *this;.inst/tinytest/cpp/Module.cpp: add aModulePropertiesclass that exposes one property perproperty()overload (member, const member and free-function getters, combined with member and free-function setters). Only two of the nine overloads were exercised before.inst/tinytest/test_module.R: set and read each read-write property, check that the read-only ones read the same value and reject assignment.Verification:
SIGTRAP(code 133) against current master and printsmodule loadedand[1] 5against this branch.test_module.Rtraps whilesourceCpp()loadscpp/Module.cppagainst master's headers (the whole file aborts), and passes on this branch (55/55).test_module.R,test_modref.R,test_expose_class.Randtest_module_client_package.Rpass withRunAllRcppTests=yes RunVerboseRcppTests=yeson R 4.6.1 / macOS. (test_module.Rstill printsError: Expecting an external pointer: [type=environment].at exit; that is the dummy-object finalizer fixed separately in make finalize() a no-op for never-constructed module objects #1518.)Checklist
R CMD checkstill passes all tests (module test files run locally as above; the change is a one-line header fix plus tests)