-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Even more gcc warning options #38222
Merged
ZhilkinSerg
merged 10 commits into
CleverRaven:master
from
jbytheway:gcc_warning_options
Feb 24, 2020
Merged
Even more gcc warning options #38222
ZhilkinSerg
merged 10 commits into
CleverRaven:master
from
jbytheway:gcc_warning_options
Feb 24, 2020
Conversation
This file contains 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
These don't trigger anything in our code, but are useful gcc warnings to have enabled.
src/game.cpp:6841:9: error: macro is not used [-Werror,-Wunused-macros] #define MAXIMUM_ZOOM_LEVEL 4
|
ZhilkinSerg
added
[C++]
Changes (can be) made in C++. Previously named `Code`
Code: Build
Issues regarding different builds and build environments
labels
Feb 22, 2020
|
jbytheway
force-pushed
the
gcc_warning_options
branch
from
February 22, 2020 12:42
fb8c998
to
8559c66
Compare
This warning detects classes with virtual functions but a non-virtual destructor. Deleting instances through pointers whose type is such a class is undefined behaviour. I'm not certain whether any of the classes I've added the virtual destructors to here actually needed it, but there should be negligible performance impact, and it's a good warning to have enabled.
jbytheway
force-pushed
the
gcc_warning_options
branch
from
February 22, 2020 12:58
8559c66
to
79b5ab7
Compare
Turns out it's not actually supported by gcc 5.3.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
[C++]
Changes (can be) made in C++. Previously named `Code`
Code: Build
Issues regarding different builds and build environments
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.
Summary
SUMMARY: None
Purpose of change
More compiler checks.
Describe the solution
Adding:
-Wformat-signedness
which looks for e.g.printf("%d", n);
wheren
is unsigned. There was one example of this in the tests.-Wlogical-op
which looks for e.g.a & b
which should probably have beena && b
. No hits on this one, but it seems like a good warning to have.-Wnon-virtual-dtor
which looks for classes with virtual functions but non-virtual destructors. Deleting pointers of such type can be UB. There were a few cases; I'm not sure whether any of them were actually being used incorrectly, but unless there's an extreme performance requirement then we should play it safe.-Wredundant-decls
which looks for duplicate function declarations. There were a couple of these which essentially amounted to functions being declared rather than the proper header being included.(turned out not to be supported by gcc 5.3)-Wrestrict
which looks for violations of therestrict
keyword. That only exists in C++ as an extension, I think. In any case, no examples highlighted.-Wunused-macros
which looks for unused macros declared incpp
files (of course, it can't know whether macros in headers are unused. It found a few such.-Wzero-as-null-pointer-constant
which is another way to encourage use ofnullptr
. There was one example, in the curses build whereclang-tidy
hasn't already eliminated allNULL
s.Describe alternatives you've considered
Adding even more warnings!
Testing
Compiled and ran unit tests.
Additional context
There's a good chance that one or both of the Mingw and Android builds will fail, so don't merge until Travis has shown them to be clean.