cpp-terminal icon indicating copy to clipboard operation
cpp-terminal copied to clipboard

CI: Enable all warnings on all compilers and turn them into errors

Open certik opened this issue 5 years ago • 4 comments

That way the CI will fail if any compiler issues a warning, so that we can catch any regressions.

certik avatar Oct 10 '19 14:10 certik

But keep them as just warnings when not in the CI, that way users will not get errors if they upgrade a compiler that introduces some new warnings.

certik avatar Feb 12 '21 18:02 certik

I have checked on that: https://gcc.gnu.org/onlinedocs/gcc-10.2.0/gcc/Option-Summary.html There are many warnings available. We would have to test them with both clang and gcc on at least windows and linux. I would suggest doing that after we moved the library into seperate files, because we can turn on the warnings and errors on the library tearget directly (wich improves the debugging a lot). I would also suggest to add all flags, that disable non-c++ stuff, like gnu keywords and disable stuff like "weak functions". The abbility to turn off the compile options could be done with the same cmake options, that can turn off the example program targets. That would be a good thing to include in the wiki later on (like a simple compile with cmake section. But I would prefer to make it optional and not recommended). Also the sompile flags are only turned on on the specified targets. That means, that projects that depend on cpp-terminal don't use the extra flags at all (only if they are adding those themselves) but cpp-terminal gets compiled with those independently.

I'll create a list with all compile flags, I would suggest / recommend. We can decide then, what we use and what not. As I said, I would probably use all that are either regarding to C++ or x64/x86 architectures. (Are we even supporting x32? and / or other ones like arm64/aarch64/armV7 and so on?).

MCWertGaming avatar Feb 13 '21 14:02 MCWertGaming

I havent looked for MSVC yet. Will do that probably after we implemented the flags for linux / gcc. We have to do both seperately anyway.

MCWertGaming avatar Feb 13 '21 14:02 MCWertGaming

I have looked into it. There are many warning that we shouldn't enable, like -Wdouble-promotions, because it warns of a problem that occurs on really old 32bit pcs. So I wouldn't go with -w (wich enables all warnings). I created a list and will will go into that later.

-fno-gnu-keywords
-Wabi-tag
-Wcomma-subscript
-Wctor-dtor-privacy
-Wall
-Wextra
-Wnoexcept
-Wnoexcept-type
-Wclass-memaccess
-Wregister
-Wredundant-tags
-Wstrict-null-sentinel
-Wold-style-cast
-Woverloaded-virtual
-Wsign-promo
-Wtemplates
-Wmismatched-tags
-Wmultiple-inheritance
-Wvirtual-inheritance
-Wvolatile
-Wzero-as-null-pointer-constant
-Wextra-semi
-Wsuggest-final-types
-Wuseless-cast
-Wnull-dereference
-fdelete-null-pointer-checks
-Wmissing-include-dirs
-Wswitch-default
-Wuninitialized
-Wunused-macros
-Wundef
-Winline
// limits max errors
-fmax-errors=30
// all warnings to errors
-Werror
// only allow ISO c++
-Wpedantic

Needs testing:

// may argue about standard headers
-Weffc++
// maybe too strict
-Wunused-const-variable=2
-Wswitch-enum
-Wcatch-value=3
-Waligned-new=all
-Wconditionally-supported
-Wsuggest-final-methods
-Wsuggest-override
-Wformat=2
-Wformat-overflow=2
-Wformat-nonliteral
-Wformat-security
-Wformat-signedness
-Wformat-truncation=2
-Wformat-y2k
-Wshift-overflow=2
-Wstrict-overflow=5
-Wshadow
-Wunsafe-loop-optimizations
// Warn about code affected by ABI changes and I don't understand what that is.
-Wabi

And some analysing (haven't used that yet, can't tell if it's to be used at compiletime or just for checking, like clang-tidy does):

-Wanalyzer-too-complex 
-fanalyzer 
-fanalyzer-call-summaries 
-fanalyzer 
-fanalyzer-call-summaries 
-fanalyzer-checker=name 
-fanalyzer-fine-grained 
-fanalyzer-state-merge 
-fanalyzer-state-purge 
-fanalyzer-transitivity 
-fanalyzer-verbose-edges 
-fanalyzer-verbose-state-changes 
-fdump-analyzer 
-fdump-analyzer-stderr 
-fdump-analyzer-callgraph 
-fdump-analyzer-exploded-graph
-fdump-analyzer-exploded-nodes-3 
-fdump-analyzer-state-purge 
-fdump-analyzer-supergraph 

Hope that works. I have not included warnings, that are turned on by -Wall and -Wextra. Also I have included no C related options.

MCWertGaming avatar Feb 13 '21 17:02 MCWertGaming

replaced by #182.

MCWertGaming avatar Aug 22 '22 11:08 MCWertGaming