fix MSVC warning about control paths (fixes #3067)#3068
fix MSVC warning about control paths (fixes #3067)#3068jameslamb merged 3 commits intolightgbm-org:masterfrom
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 |
😱 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 |
StrikerRUS
left a comment
There was a problem hiding this comment.
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 👀 |
…gbm-org#3068) * [R-package] fix MSVC warning about control paths (fixes lightgbm-org#3067) * linting * simplify
…gbm-org#3068) * [R-package] fix MSVC warning about control paths (fixes lightgbm-org#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::FatalcallsRf_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
PredictionEarlyStopInstanceto 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.Rthat the warning is gone: