4 ms·
Many answers suggest passing -Wall -Wextra to the compiler. In my experience, this misses many useful warnings. Here's a good list of additions warnings that us
by slacka 7y ago
Many answers suggest passing -Wall -Wextra to the compiler. In my experience, this misses many useful warnings. Here's a good list of additions warnings that usually produce useful results:
https://kristerw.blogspot.com/2017/09/useful-gcc-warning-options-not-enabled.html https://kristerw.blogspot.com/2017/09/useful-gcc-warning-opt...
- ohazi 7y agoI never really understood why "all" wasn't actually a catch-all. If it's not a catch-all, don't call it all. Or at least give us a -Wallyesreally, which doesn't currently exist afaik
- MaxGabriel 7y agoGHC (Haskell) has -Weverything which is great for this. I’d much rather get all warnings and blacklist the few I don’t want
- ridiculous_fish 7y ago-Weverything is also part of clang. An example of a warning is "this struct has a padding byte between these two fields." A blacklist would be painful. -Weverything should be thought of as a tool for discovering new warning flags relevant to your project. Add those flags, but don't enable -Weverything for routine builds, unless you're a masochist.
- cpeterso 7y agoBarrow/compiler-warnings is a nice reference for all Chang and gcc warning flags, which flags implicitly enable other warnings, and in which compiler version they were added: https://github.com/Barro/compiler-warnings/ https://github.com/Barro/compiler-warnings/
- mcpherrinm 7y agoClang has -Weverything: https://clang.llvm.org/docs/UsersManual.html#diagnostics-enable-everything https://clang.llvm.org/docs/UsersManual.html#diagnostics-ena... The problem with -Wall is that people use it with -Werror, thus compilers would have to be very conservative about adding new warnings to it. Hence the situation we are in with a few flags "above and beyond". Most of -Wpedantic for example is not something I'd want to break my build on. The following stack overflow answer has some good example of other warnings you probably don't want, but would be included in -Weverything: https://stackoverflow.com/questions/11714827/how-to-turn-on-literally-all-of-gccs-warnings https://stackoverflow.com/questions/11714827/how-to-turn-on-...
- zik 7y agoI'd argue that if you used -Wall and you got all the warnings you can't really complain too much because you got exactly what you asked for.
- greglindahl 7y agoThat's fine for an argument in a bar, and not so helpful for people who are doing software engineering with code that is developed under multiple compiler versions. Or who build old code versions with a new compiler version.
- reitzensteinm 7y agoWhy are "people who are doing software engineering" expecting to build code in a new compiler without migration effort, and ignoring new warnings that have been added potentially pointing to existing undetected issues just so the code continues to compile? "People who want to get shit done", sure. Pragmatists, even.
- monadgonad 7y agoIt's only not so helpful because -Wall is badly named and now we're forced to deal with that legacy. Ideally, -Wall would be the same as clang's -Weverything, and there'd be a -Wstandard (or something) flag for what -Wall currently does.
- enriquto 7y agowow, I'm astonished that -Wshadow is not enabled by either -Wall nor -Wextra
- wyldfire 7y agoLots of shadowing is present in existing codebases, sometimes by design.
- ilaksh 7y agoLOL. I did not realize "all" was not all. Jesus Christ. Maybe I will finally be able to figure out what is causing my program to crash.
- saagarjha 7y agoI’d recommend using a sanitizer rather than relying on compiler warnings for this.
- ilaksh 7y agoI tried to use some sanitizers but they seemed unavailable for my system. I am on MSYS2 with GCC 9.