-
Notifications
You must be signed in to change notification settings - Fork 17
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
Recommendations for enabling more compiler checks #37
Comments
My proposal for 🍇 is:
Note: all the above flags ARE NOT turned on by default in clang++ (according to https://clang.llvm.org/docs/DiagnosticsReference.html). If they were then there would be no need to list them explicitly. My proposal for 🍊 is:
My proposal for 🍏 is:
🍎 proposal is: clang++ only
g++ onlyTODO: develop our recommended list based on testing https://kristerw.blogspot.de/2017/09/useful-gcc-warning-options-not-enabled.html |
One important tip here: All code that is |
I want to flag the following:
|
Thanks @joto: Absolutely agree that, to allow more aggressive warnings in your code (and especially @daniel-j-h - thanks for these links. So far the flags I'm recommending above work in both recent g++ and clang++. Your links raise the issue that it would be useful to also develop recommended lists of additional warnings to enable, per compiler. I will edit inline above to add another section specific to compilers. Then I will plan to PR a doc that will list these and we can iterate on that doc. |
enable more warnings/make them errors per mapbox/cpp#37
Compilers enable by default, a set of warnings they will emit on dodgy or less-than-ideal code. These defaults:
This issue is designed to focus on the problem of
c
from the perspective of the latest clang++ 4.x versions.Enabling more warnings than compilers do by default can be an important way of catching bugs early. For example integer truncation bugs can often be detected by enabling
-Wconversion
, which is not on by default.Enabling more warnings is very difficult to do after a project is big (e.g. Project-OSRM/osrm-backend#4495 and mapnik/mapnik#2907 and mapnik/mapnik#3204). It is best not to wait and rather to start a project with aggressive warnings from the beginning.
So, the question then becomes: what is a good set of aggressive warnings to enable at the start of a project (or to try to integrate into existing projects)?
In particular:
🍇 Which flags we should always enable for all code no matter what?
🍊 What additional flags may be very useful in some scenarios/some code bases?
🍏 For small projects where it is feasible, can we actually start with
clang++
s-Weverything
? This, when feasible, might be ideal. How to do it?🍎 What compiler specific flags should we recommend (that only currently work for clang++ or g++)?
The text was updated successfully, but these errors were encountered: