I’ve compiled a list of commonly enabled compiler diagnostics that we are currently choosing not to enable.
This is the list:
Compiler diagnostic | no# of emitted unique GCC warnings in master |
no# of emitted unique Clang warnings in master |
---|---|---|
-Wconditional-uninitialized : Warn if a variable may be uninitialized when used |
Not supported | 2 |
-Wdouble-promotion : Warn if float is implicit promoted to double |
1 | 8 |
-Wduplicated-branches : Warn if if /else branches have duplicated code |
0 | Not supported |
-Wduplicated-cond : Warn if if /else chain has duplicated conditions |
0 | Not supported |
-Wfloat-equal : Warn if floating-point values are used in equality comparisons |
29 | 18 |
-Wlogical-op : Warn about logical operations being used where bitwise were probably wanted |
0 | Not supported |
-Wnon-virtual-dtor : Warn the user if a class with virtual functions has a non-virtual destructor. This helps catch hard to track down memory errors. |
22 | 10 |
-Wnull-dereference : Warn if a potential nullptr dereference is detected |
48 | Not supported |
-Woverloaded-virtual : Warn if you overload (not override ) a virtual function |
0 | 0 |
-Wsuggest-override : Warn about overriding virtual functions that are not marked with the override keyword |
303 (of which 192 are in src/leveldb/ |
Not supported |
-Wunreachable-code-loop-increment : Warn if a loop will run only once (loop increment never executed) |
Not supported | 1 |
-Wunused-member-function : Warn on unused member function |
Not supported | 2 |
-Wunused-template : Warn on unused template |
Not supported | 1 |
There is a large overlap between this list and Jason Turner’s list of recommended compiler diagnostics in the Collaborative Collection of C++ Best Practices (cppbestpractices
) project. There is also an overlap with the recommendations given in the C++ Core Guidelines (with editors Bjarne Stroustrup and Herb Sutter).
I’m now seeking feedback regarding these diagnostics: which of these would make sense to enable in the Bitcoin Core project? :)