Giter Club home page Giter Club logo

Comments (10)

lefticus avatar lefticus commented on May 30, 2024 2

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.

ljishen avatar ljishen commented on May 30, 2024

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.

janwilmans avatar janwilmans commented on May 30, 2024

more suggestions:

-Wconversion 
-Wsign-conversion 
-Wmissing-include-dirs 
-Wformat=2 
-Wunused 
-Wunused-variable 
-Wcast-align 
-Wno-vla 
-Wnull-dereference
-Wshadow

from project_options.

janwilmans avatar janwilmans commented on May 30, 2024

and (but only for C++) -Wnon-virtual-dtor -Woverloaded-virtual

from project_options.

ClausKlein avatar ClausKlein commented on May 30, 2024

'-Wno-vla' seems to disable a warning?

from project_options.

aminya avatar aminya commented on May 30, 2024

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.

aminya avatar aminya commented on May 30, 2024

'-Wno-vla'

It disallows the use of variable-length C arrays. I am wondering if this is already covered by -Wpedantic

from project_options.

janwilmans avatar janwilmans commented on May 30, 2024

from project_options.

FeignClaims avatar FeignClaims commented on May 30, 2024

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.

Project579 avatar Project579 commented on May 30, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.