[R-package] use safer pattern for error formatting (fixes #6212)#6216
Merged
[R-package] use safer pattern for error formatting (fixes #6212)#6216
Conversation
Collaborator
Author
|
@guolinke @shiyu1994 sorry for the Thank you. |
Collaborator
Author
|
thanks @guolinke ! |
This was referenced Dec 1, 2023
Contributor
|
This pull request has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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 #6212.
Resolves warning
-Wformat-securityraised with R-devel as of a few days ago andclang-15:See #6212 (comment) for more details informing the changes in this PR.
Why not just suppress this warning?
CRAN has in the past not allowed compiler flags or pragmas in code that suppress warnings.
LightGBM/build-cran-package.sh
Lines 140 to 143 in 2ee3ec8
I couldn't find that stated explicitly in the CRAN policy (https://cran.r-project.org/web/packages/policies.html) or Writing R Extensions (https://cran.r-project.org/doc/manuals/R-exts.html), although there are some valid things there that note that warning-control flags can be compiler-specific and therefore add maintenance complexity to achieve portability. e.g. from https://cran.r-project.org/doc/manuals/R-exts.html#Portable-C-and-C_002b_002b-code
So unless there's some other performance, safety, or correctness issue I'm unaware of, I think the fix in this PR is a good approach to satisfying
clang-15and therefore the CRAN checks.Notes for Reviewers
@shiyu1994 @guolinke @jmoralez this PR will unblock LightGBM's CI.
@david-cortes if you have other opinions on the approach I took here I'd welcome them.