-
Notifications
You must be signed in to change notification settings - Fork 597
Fix misc compiler warnings #10609
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
base: master
Are you sure you want to change the base?
Fix misc compiler warnings #10609
Conversation
8dd2cd0 to
05b635d
Compare
Al2Klimov
left a comment
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.
MSVC gave a warning here due to differences between the type of the argument to emplace_back() and the type of the pair component.
a25c3f1 to
289607b
Compare
lib/config/expression.cpp
Outdated
| else | ||
| VERIFY(!"Invalid scope."); | ||
|
|
||
| VERIFY(!"Invalid scope."); | ||
| return Empty; |
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.
Which compiler did complain about this? I'm not able to find this kind of warning in the GHAs logs or locally on my machine. The previous version was pretty obvious that it will never return since it's negating a statically provided string, and I'm a bit surprised that the compiler isn't able to figure this out as the icinga_assert_fail function is annotated with a noreturn attribute.
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.
I compiled several times with multiple sets of flags and both GCC and clang because I didn't realize where I got the warning: It's MSVC.
I think __declspec(noreturn) is supposed to fix this here, but it doesn't. I'll look into what's missing.
| } | ||
|
|
||
| allFiles.emplace_back(Utility::GetTime() + 1, GetApiDir() + "log/current"); | ||
| allFiles.emplace_back(static_cast<int>(Utility::GetTime()) + 1, GetApiDir() + "log/current"); |
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.
Uhmm, casting double to int? I know that this was implicitly done previously but this is just totally wrong. I would just change the type of the first pair in allFiles to double and adjust LogGlobHandler accordingly.
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.
While I agree that using double everywhere would make more sense here, I wanted to change as little as possible and only fix the warnings here.
Also it's not "totally wrong". static_casting double to int is perfectly valid, especially since it's done explicitly. It's just truncating the double value to whole seconds.
Oh, forgot to send my reply to this. These warning don't exist on my machine and replacing $ bison --version
bison (GNU Bison) 2.3
Written by Robert Corbett and Richard Stallman
---And after going through the Bison docs, there's quite no difference between |
289607b to
4389abf
Compare
Together with #9411, #9728, #9729 and #9730 this fixes most of the remaining compiler warnings, except the following:
-Wdangling-referenceinscheduleddowntime-apply.cpp, which I'm pretty sure are false positives.-Wdeprecated-declarationswarnings.%pure-parserbeing deprecated in the.yyparser files. At first I wanted to include them here, but despite things seemingly building fine it seems there's some additional implications with replacing%pure-parserwith%define api.pureand%error-verbosewith%define parse.error verbosethat I can't judge because I'm not a bison expert.