Skip to content

Fix -Wunused-parameter (Clang only) - #1536

Merged
eddelbuettel merged 1 commit into
RcppCore:masterfrom
SoapGentoo:fix-Wextra
Nov 27, 2026
Merged

eddelbuettel merged 1 commit into
RcppCore:masterfrom
SoapGentoo:fix-Wextra

Conversation

@SoapGentoo

@SoapGentoo SoapGentoo commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Unlike GCC, Clang warns about unused parameters in uninstantiated templates, breaking every TU that includes Rcpp under -Wextra -Werror.

Pull Request Template for Rcpp

Please explain the changes you want to apply to Rcpp, preferably in an issue ticket before you create a pull request. See the file Contributing and the other templates for details.

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

Unlike GCC, Clang warns about unused parameters in uninstantiated
templates, breaking every TU that includes Rcpp under `-Wextra -Werror`.
@eddelbuettel

Copy link
Copy Markdown
Member

Thanks. I think our status is still 'progress towards -Wextra -Werror'.

@eddelbuettel

eddelbuettel commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

I just tried to random packages of mine with clang++-22 and there are many other problem with -Wextra -Werror. Did you have a particular 'reference' package compilation here?

@SoapGentoo

SoapGentoo commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

This was Clang 23.1.6 (and GCC 16.2.1, but that one was fine) against -O{0..3} and this was the only fallout I got. I hadn't tested it against any Rcpp reverse dependency itself, no. If you want, I can fix those too

@eddelbuettel

Copy link
Copy Markdown
Member

So you got this from installing Rcpp itself?

@SoapGentoo

SoapGentoo commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor Author

I've compiled every C++ file in this repo with

clang++ -std=gnu++20 -I/usr/lib64/R/include -I<tree>/inst/include -DNDEBUG -fPIC -O<n> -Wall -Wextra -Werror -c <file>.cpp -o /dev/null

@eddelbuettel

Copy link
Copy Markdown
Member

Thanks for being more specific and getting a reproducible example. What my first comment above was trying to hint at was that I do not think we claim that -Wextra -Werror can generally be used.

Your PR is fine as such ("does no harm"), I just want to make sure we are at the same starting position. Unless I am mistaken, I think we never claimed one could use -Wextra -Werror (because given the wide use of Rcpp there is likely always something here there or everywhere (as I just got with both a small and a larger package touching Boost via our BH package). So I would like to avoid a goose chase here. The PR is likely fine in isolating, but let's agree to not make this the base camp of a massive expedition to follow.

@SoapGentoo

Copy link
Copy Markdown
Contributor Author

I saw the fixes in 1835865 so just decided to rebase my branch from half a year ago, and this one was left over. RcppArmadillo compiles cleanly for me too after a manual compileAttributes() which you also fixed already.

@eddelbuettel

Copy link
Copy Markdown
Member

Thanks for the pointer. I knew we had "done something", I also had the hunch there is still a lot to do so we cannot claim "all is well today for -Wextra -Werror. We got one specific error, your PR does indeed help with the same coverage.

@eddelbuettel eddelbuettel left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verified locally against the installed Rcpp headers (1.1.2.8, unpatched):

  • Reproduced the failure: clang++ -Wunused-parameter -Werror on a TU including <Rcpp.h> errors at inst/include/Rcpp/internal/wrap.h:526 — the exact uninstantiated-template parameter the PR cites. GCC-15 compiles cleanly, matching the "Clang only" claim.
  • Patched header compiles clean across C++11/14/17/20 under that flag, and the /*object*/ idiom matches existing usage in Module.h / Promise.h / StretchyList.h.
  • Semantics unchanged: the commented-out name lives in the unreachable fallback overload (the static_assert is its only real content), and the tag-dispatch overload selection is untouched.
  • ChangeLog entry present and in house format.

One note: with a full -Wextra -Werror build, 7 further errors remain (clang's -Wdeprecated-copy-with-user-provided-copy in proxy headers), as already flagged in the comments — this is progress towards -Wextra -Werror, not full compliance. Worth not advertising it as such.

Approving. No test added for the warning: a build-flag regression test isn't practical and CI doesn't gate on -Wextra -Werror.

(NB: The approval comment and underlying (local) tests were done with the assistance of inkling-2-mini.)

@eddelbuettel

Copy link
Copy Markdown
Member

I will wait a bit for other Rcpp team members to chime in but I think we're good and I plan to merge. Thanks for the fix!

@Enchufa2

Copy link
Copy Markdown
Member

LGTM!

@eddelbuettel

eddelbuettel commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

I think we never claimed one could use -Wextra -Werror

Clarifying / rewording: I think our prior position was something along the lines of 'we are sympathetic to the goals of -Wextra -Werror and hence the earlier PR. This one is indeed a further step in that direction to avoid clang++ stumbling here.

@eddelbuettel
eddelbuettel merged commit 279801e into RcppCore:master Nov 27, 2026
15 checks passed
@SoapGentoo
SoapGentoo deleted the fix-Wextra branch November 27, 2026 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants