3 ms·
C and C++ developers who have been around long enough understand why clang specifically says not to regularly use -Weverything. Historically even -Wextra has r
by wahern 4y ago
C and C++ developers who have been around long enough understand why clang specifically says not to regularly use -Weverything.
Historically even -Wextra has resulted in spurious warnings for perfectly valid and clean code, as most if not all -Wextra warnings are heuristics. -Weverything is also all heuristics, but even more volatile and debatable. Any worthwhile -Weverything heuristic will eventually move to -Wextra.
So, sure, use -Weverything on occasion to see if there's anything interesting to take note of. But if you include it by default you're inviting fatigue and unnecessary rewrites, which may be just as likely to result in the introduction of bugs as to fix any bugs.
- gavinhoward 4y agoI think this depends on the person. I love -Weverything. I turn off two warnings by pragma in headers (-Wpadded, -Wc++98-compat), but other than that, I make the code obey all of warnings. This means things like explicitly marking unused arguments, marking pointer casts with a void pointer cast (with an assert to ensure alignment is okay), etc. But my code will build cleanly everywhere. That's really nice.
- zamnos 4y agoInteresting. I'm from a different part of industry so x86_64 Linux is support is enough, where is "everywhere" for you?
- gavinhoward 4y agoLinux, BSD's, Mac OSX, and Windows, on x86, x86_64, ARM, aarch64, and the many architectures supported by Gentoo Linux.
- zamnos 4y agoGotcha, thanks.
- shrimp_emoji 4y agoBased. In the epistemically Lovecraftian realm of UB insanity that is C and C++, I happily kneel at the altar of following petty rules if it means it can keep my code safer from bugs. The post author is basically staring in the face of decades of mind-rending CVEs and, when glancing over to something that can preclude most of them, says, "Yeah but this is annoying and distracting. I need to not be annoyed or distracted so that I can focus on writing good code (unlike all the programmers that came before me)."
- gavinhoward 4y agoHeh. Me too. https://gavinhoward.com/2023/02/why-i-use-c-when-i-believe-in-memory-safety/ https://gavinhoward.com/2023/02/why-i-use-c-when-i-believe-i... And I agree. That author is not doing everything he can.
- wahern 4y ago> when glancing over to something that can preclude most of them That's where we vehemently disagree. IME some diagnostics promote worse code. But my argument regarding -Weverything comes down to something more practical--your code may compile today, but it will stop compiling tomorrow when the suite of diagnostics and their implementation change. And in a project maintained by more than one person, attempting to keep abreast of -Weverything is a losing battle, with the only benefit being aesthetic. Again, useful diagnostics will migrate to -Wextra, and the best of them to -Wall. You're arguing against a strawman, alluding to those who resist -Wextra or even -Wall. But -Weverything is defined as a testing bed for diagnostics. By definition even the compiler maintainers disagree about the value--how much it helps versus incentivizes unnecessary, even dangerous code modifications. Rather than relying on -Weverything to identify flaky C or C++ code, perhaps one should look into not using those languages for the bulk of their application. That way you avoid the most problematic areas of C and C++. Running around throwing casts everywhere to satisfy -Weverything is running in the wrong direction. -Weverything to my mind is something that might only seem useful to those copy+pasting code from Stack Exchange or now GPT. I'll stick with my well worn copy of the C and C++ standards, and spending my time proving the correctness of hairy code.
- 4y ago