GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Lay the ground for Rf_error masking (#1402) by Enchufa2 · Pull Request #1407 · RcppCore/Rcpp

Conversation

@Enchufa2

@Enchufa2 Enchufa2 commented Nov 12, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

First step to #1247

  • Add a message at compilation time
  • Protect the valid Rf_error calls generated by Rcpp

Checklist

  • Code compiles correctly
  • R CMD check still passes all tests
  • Preferably, new tests were added which fail without the change
  • Document the changes by file in ChangeLog

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Enchufa2
Enchufa2 requested review from Copilot, eddelbuettel and kevinushey November 12, 2025 17:24
Copilot started reviewing on behalf of Enchufa2 November 12, 2025 17:28
View session
Copilot finished reviewing on behalf of Enchufa2 November 12, 2025 17:29
Copilot AI reviewed Nov 12, 2025
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR lays the groundwork for masking unsafe Rf_error() calls by introducing a macro that generates compilation messages warning users to use Rcpp::stop() instead. This is the first step toward addressing issue #1247.

  • Adds a new macro header file that redefines Rf_error() to emit a compilation warning message
  • Protects legitimate Rf_error() calls in Rcpp-generated code using parentheses (Rf_error)() to bypass the macro
  • Provides an opt-out mechanism via RCPP_NO_MASK_RF_ERROR for false positives

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
inst/include/Rcpp/macros/mask.h New file introducing the Rf_error macro that shows a compilation message directing users to Rcpp::stop()
inst/include/RcppCommon.h Includes the new mask.h header file at the end of the common includes
src/attributes.cpp Protects auto-generated Rf_error call with parentheses to prevent macro expansion
inst/tinytest/cpp/stack.cpp Protects test code's Rf_error call with parentheses and updates copyright
inst/tinytest/testRcppInterfaceExporter/src/RcppExports.cpp Protects auto-generated Rf_error call with parentheses
ChangeLog Documents all changes made in this PR

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
eddelbuettel
eddelbuettel approved these changes Nov 12, 2025
View reviewed changes

@eddelbuettel eddelbuettel left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

Also better than my PR where @copilot always finds a typo to nag about.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@Enchufa2

Enchufa2 commented Nov 14, 2025

Copy link
Copy Markdown
Member Author

So, as discussed, and the revdep machine made it clear, we cannot generate a note. Pragma messages are considered statements by gcc (see e.g. here and bugs linked there). Options are: be silent, or generate a warning without replacing.

In order to ask CRAN about what they think, we need to calculate how many packages would generate this warning. An upper bound was provided here by just grepping the sources of all reverse dependencies: 263 packages. From these, only 24 would also fail compilation or checks as documented in #1406. To further refine this list, we could collect the install logs and grep for the pragma (are they in the revdep machine from the previous run?).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

eddelbuettel
eddelbuettel reviewed Nov 14, 2025
View reviewed changes
Comment thread inst/include/Rcpp/macros/mask.h Resolved

Uh oh!

There was an error while loading. Please reload this page.

@Enchufa2
Enchufa2 force-pushed the feature/pre_mask_Rf_error branch from ce5cee3 to 461e8ad Compare December 9, 2025 12:42
@Enchufa2
Enchufa2 force-pushed the feature/pre_mask_Rf_error branch from 461e8ad to c4f682a Compare December 16, 2025 16:09
@Enchufa2
Enchufa2 requested a review from eddelbuettel December 19, 2025 12:39
@Enchufa2

Enchufa2 commented Dec 19, 2025

Copy link
Copy Markdown
Member Author

This is a version that emits a message instead of a warning, and avoids the problem of inserting two statements. Could we run a revdep with this?

eddelbuettel reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Enchufa2
Enchufa2 force-pushed the feature/pre_mask_Rf_error branch from 598c0a9 to b1889a9 Compare December 19, 2025 12:52
eddelbuettel
eddelbuettel approved these changes Dec 19, 2025
View reviewed changes

@eddelbuettel eddelbuettel left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me (modulo a micro-comment), let's see what the reverse dependencies say (in due time, now running).

(I asked copilot too which often catches little gotchas.)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread inst/include/Rcpp/macros/mask.h Resolved

Uh oh!

There was an error while loading. Please reload this page.

@eddelbuettel
eddelbuettel requested a review from Copilot December 19, 2025 13:28
Copilot started reviewing on behalf of eddelbuettel December 19, 2025 13:29
View session
Copilot AI reviewed Dec 19, 2025
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@eddelbuettel

eddelbuettel commented Dec 19, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

First package to break compilation is BayesProject:

/usr/local/lib/R/site-library/Rcpp/include/Rcpp/macros/mask.h:42:23: error: invalid use of ‘::’ [-Wtemplate-body]
   42 | #define Rf_error(...) Rcpp::internal::Rf_error(__VA_ARGS__)
      |                       ^~~~
/usr/share/R/include/R_ext/Error.h:84:15: note: in expansion of macro ‘Rf_error’
   84 | #define error Rf_error
      |               ^~~~~~~~
/usr/local/lib/R/site-library/RcppEigen/include/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h:305:14: note: in expansion of macro ‘error’
  305 |   RealScalar error() const
      |              ^~~~~

It's an interaction with Boost Eigen and R 😿 This one also triggers the 'R.h included' message so a cleanup may fix both.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Enchufa2

Enchufa2 commented Dec 19, 2025

Copy link
Copy Markdown
Member Author

Ah, of course, group 1 in #1406 is expected to fail due to the inclusion of <R.h>. But we want to fix these as soon as possible.

eddelbuettel reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Enchufa2
Enchufa2 force-pushed the feature/pre_mask_Rf_error branch from 326614b to bb86312 Compare December 19, 2025 17:59
@Enchufa2

Enchufa2 commented Dec 22, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

Apologies for the back-and-forth, but the internal template thing didn't work. I thought that the message would be shown only if the template was instantiated, but that's not the case. I thought I tested it correctly, but obviously I did something wrong, because now I see messages all over the place when Rf_error is not there.

So we are back at square 1, meaning two options:

  1. Prepare things, no warning yet, but at least compileAttributes will start protecting Rf_error calls. I.e. the PR as it is right know, because I've commented out the warning.
  2. Uncomment the warning, so we will start generating warnings in hundreds of packages, although none of them would fail, it's just the warnings. CRAN knows and could "activate" this warning when they see fit.
eddelbuettel reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Enchufa2

Enchufa2 commented Dec 22, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

Let's take (1) and merge this then?

eddelbuettel reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@eddelbuettel

eddelbuettel commented Dec 22, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

Yes. Let me catch my breath after all the excitement in #1430 and get back to you.

Enchufa2 reacted with laugh emoji
All reactions
  • 😄 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

eddelbuettel
eddelbuettel reviewed Dec 22, 2025
View reviewed changes

@eddelbuettel eddelbuettel left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, but ... it now does nothing?

So shall we merge this as a placeholder to be activated once 'group 1' of R.h has been cleaned up?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@eddelbuettel

eddelbuettel commented Dec 22, 2025

Copy link
Copy Markdown
Member

Should we maybe not comment it out (as right now) but make it active behind an 'opt-in' environment variable? Then we could merge now, and we (and Kurt) can run with the variable set. Better?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Enchufa2 added 4 commits December 23, 2025 13:35
@Enchufa2
Lay the ground for Rf_error masking (#1402)
e39cd00
* Add a message at compilation time
* Protect the valid Rf_error calls generated by Rcpp
@Enchufa2
some rewording to fit the ChangeLog text in two lines
81fe90a
@Enchufa2
messages are considered statements by gcc and cannot be used safely; …
98bd3b2
…switching to a warning
@Enchufa2
rebase fix
119d6b9
Enchufa2 added 5 commits December 23, 2025 13:35
@Enchufa2
emit a message instead of a warning using an internal wrapper
04349c9
@Enchufa2
remove space
b4a9f2a
@Enchufa2
Revert "remove space"
7d592e3
This reverts commit bb86312.
@Enchufa2
Revert "emit a message instead of a warning using an internal wrapper"
b06ea93
This reverts commit 9d409e8.
@Enchufa2
comment out warning
6b326a6
@Enchufa2
Enchufa2 force-pushed the feature/pre_mask_Rf_error branch from b0a804b to ae9cd85 Compare December 23, 2025 12:35
@Enchufa2
add on switch
f5857fb
@Enchufa2
Enchufa2 force-pushed the feature/pre_mask_Rf_error branch from ae9cd85 to f5857fb Compare December 23, 2025 12:37
@Enchufa2

Enchufa2 commented Dec 23, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

Sounds good to me. Here it is with an on switch.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

eddelbuettel
eddelbuettel approved these changes Dec 23, 2025
View reviewed changes
@eddelbuettel

eddelbuettel commented Dec 23, 2025

Copy link
Copy Markdown
Member

Looks like a double env var :) That'll do.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Enchufa2

Enchufa2 commented Dec 23, 2025

Copy link
Copy Markdown
Member Author

Yes, it's a great idea. CRAN may inject that flag when they're ready to process such warnings. In June the warning may be unconditional (unless disabled explicitly), then next year this may be an error. Thanks, merging here!

eddelbuettel reacted with rocket emoji
All reactions
  • 🚀 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Enchufa2
Enchufa2 merged commit fd7ad87 into master Dec 23, 2025
26 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@Enchufa2
Enchufa2 deleted the feature/pre_mask_Rf_error branch December 23, 2025 14:14
@eddelbuettel

eddelbuettel commented Dec 26, 2025

Copy link
Copy Markdown
Member

So for completeness I ran a reverse-dependency check over what is now in the main branch as 1.1.0.13, and a single package came up with an issue: a std::min( an_int, new_nrow()) balked because we now return R_xlen_t. I made a quick PR for the affected package (see here, I also slipped in a 'vistor' to replace one ATTRIB()) so we should be good to go.

Enchufa2 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@eddelbuettel eddelbuettel eddelbuettel approved these changes
@kevinushey kevinushey Awaiting requested review from kevinushey

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@Enchufa2 @eddelbuettel
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.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.