-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
fix MSVC warning about control paths (fixes #3067) #3068
fix MSVC warning about control paths (fixes #3067) #3068
Conversation
@jameslamb I think this warning can be fixed with less diff and without requiring code modification in multiple place for further updates (with the current fix one should update first LightGBM/include/LightGBM/prediction_early_stop.h Lines 15 to 23 in 0a4a7a8
|
😱 this is great! I'll try it. |
Ah, it was expected. Return type should match function signature. I imbedded code of |
ohhhhhhhh I misunderstood, ok I like that |
Ok just pushed a change to be sure a Seems from my fork that this works and suppresses the warning: https://dev.azure.com/JayLamb20/jameslamb-lightgbm/_build/results?buildId=508&view=logs&j=9f61088a-36ee-57e4-0947-03329fd6ee90&t=9f61088a-36ee-57e4-0947-03329fd6ee90 ^ don't worry about that build failing. I added this to Rscript build_r.R
Check-Output $false |
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.
Thanks!
But I don't think that this PR should be marked as [R-package]
. R-package allowed only to spot the warning due to compiler version.
I think it is R-package specific. I think that the warning is only spotted because This warning doesn't show up for non-R builds with MSVC, e.g. the There are no warnings around |
We use VS 2017 there, but your screenshot from the original message shows that you were using VS 2019. Also please note that the same warnings fixed in #2866 were spotted only in |
ohhhhhhh ok I see! I'm fine to leave |
94e3d08
to
0da6025
Compare
Adding that now I see this warning with MinGW This has become an |
gently pinging C++ reviewers for a review. I think this one should be quick 👀 |
…t#3068) * [R-package] fix MSVC warning about control paths (fixes microsoft#3067) * linting * simplify
…t#3068) * [R-package] fix MSVC warning about control paths (fixes microsoft#3067) * linting * simplify
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. |
See #3067 for details. When building for the R package,
Log::Fatal
callsRf_error
:https://github.com/microsoft/LightGBM/blob/master/include/LightGBM/utils/log.h#L123
That function will result in a fatal error, but not on the C++ side...it tells the calling R process to throw n R error. I think that is why MSVC thinks it's possible for control to reach the end of
PredictionEarlyStopInstance
.In this PR, I'd like to propose refactoring
PredictionEarlyStopInstance
to make it clearer to compilers that this function's control flow does always end.We don't have CI for MSVC + R builds yet (it's in progress in #2965 ), but I tested this on my laptop tonight (Windows 10, Visual Studio 16 2019, R 3.6.1, Rtools 3.5). You can see in this log from running
Rscript build_r.R
that the warning is gone: