Comments (10)
I fully agree that we should do a pass over the existing warning flags set, but I think it should be more nuanced than this.
Right now I know there is some redundant flags. For example, the -Wwrite-strings
is listed as "enabled by default" on Clang's warning page. I know there are others that are currently enabled that we should consider removing while we add new ones that were not previously covered.
Another one to consider is -pedantic-errors
, which according to the GCC documentation does "This is not equivalent to -Werror=pedantic, since there are errors enabled by this option and not enabled by the latter and vice versa." but it gives no further explanation.
from project_options.
Some of these warnings may only be available for C and not C++ in GCC. For example, -Wmissing-prototypes
, -Wnested-externs
, -Wold-style-definition
, and -Wstrict-prototypes
.
from project_options.
more suggestions:
-Wconversion
-Wsign-conversion
-Wmissing-include-dirs
-Wformat=2
-Wunused
-Wunused-variable
-Wcast-align
-Wno-vla
-Wnull-dereference
-Wshadow
from project_options.
and (but only for C++) -Wnon-virtual-dtor -Woverloaded-virtual
from project_options.
'-Wno-vla' seems to disable a warning?
from project_options.
more suggestions:
-Wconversion -Wsign-conversion -Wmissing-include-dirs -Wformat=2 -Wunused -Wunused-variable -Wcast-align -Wno-vla -Wnull-dereference -Wshadow
Many of these are already enabled. Could you find the ones that are not?
https://github.com/aminya/project_options/blob/main/src/CompilerWarnings.cmake
from project_options.
'-Wno-vla'
It disallows the use of variable-length C arrays. I am wondering if this is already covered by -Wpedantic
from project_options.
from project_options.
Here's my extra warnings:
CLANG_WARNINGS
-Wfloat-equal # warn on comparing floating point with == or !=
-Wglobal-constructors # warn on declare global or static variables with dynamic constructors
-Wmisleading-indentation # warn if indentation implies blocks where blocks do not exist
-Wmissing-noreturn # warn about functions that might be candidates for [[noreturn]]
-Wpacked # warn if a structure is given the packed attribute, but the packed attribute has no effect on the layout or size of the structure
-Wpointer-arith # warn on pointer arithmetic
-Wundef # warn if an undefined identifier is evaluated in an #if directive
GCC_WARNINGS
-Wdisabled-optimization # warn if a requested optimization pass is disabled. often, the problem is that your code is too big or too complex
-Wfloat-equal # warn on comparing floating point with == or !=
-Wglobal-constructors # warn on declare global or static variables with dynamic constructors
-Winvalid-pch # warn if a precompiled header is found in the search path but cannot be used
-Wmisleading-indentation # warn if indentation implies blocks where blocks do not exist
-Wmissing-format-attribute # Warn about function pointers that might be candidates for format attributes
-Wmissing-include-dirs # warn if a user-supplied include directory does not exist
-Wmissing-noreturn # warn about functions that might be candidates for [[noreturn]]
-Wpacked # warn if a structure is given the packed attribute, but the packed attribute has no effect on the layout or size of the structure
-Wpointer-arith # warn on pointer arithmetic
-Wredundant-decls # warn if anything is declared more than once in the same scope, even in cases where multiple declaration is valid and changes nothing
-Wundef # warn if an undefined identifier is evaluated in an #if directive
Note that -Wglobal-constructors
warns on global singleton so it will be annoying when using unit test library such as google test.
from project_options.
There is a repo on github with an up to date list of all warnings for gcc and clang, including only unique ones, it can be used to extract interesting warnings, diffs between versions are also available:
https://github.com/pkolbus/compiler-warnings/blob/main/gcc/warnings-unique-13.txt
https://github.com/pkolbus/compiler-warnings/blob/main/clang/warnings-unique-16.txt
from project_options.
Related Issues (20)
- cmake policy warnings HOT 1
- Macro for installing conan HOT 3
- Doxygen options overwrite HOT 1
- Warning is valid for C++/ObjC++ but not for C
- Cross-compiling HOT 10
- conancenter remote name is not conan's default
- After 0.26, cmake configuration has fail with 'Unable identify compiler architecture for CMAKE_SYSTEM_PROCESSOR' HOT 16
- `target_link_system_directories` dosen't support generator expressions that have semicolons
- Conan server errors inside CI HOT 1
- Support Conan 2 HOT 9
- When compiling with LTO compiler warnings should be passed to the linker. HOT 2
- Add an option to enable GCC 10+ analyzer HOT 2
- Add utility function to check if sanitizers are supported
- dynamic_project_options:
- target_find_dependencies with COMPONENT HOT 2
- target_find_dependencies and pkg-config HOT 10
- Using clang-cl with ENABLE_COVERAGE lead to 'argument unused during compilation: '-O0'' HOT 1
- Bincrafter's Conan repo down HOT 5
- `target_link_system_libraries` might not work with unqouted inputs HOT 2
- Hardening and LTO are not set correctly when using a multi-configuration generator
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from project_options.