4 ms·
The order should be as follows: - automated testing; - -Wall -Wextra, and -Weverything with some exceptions; - address, memory, thread, and undefined sanitiz
by zX41ZdbW 4y ago
The order should be as follows:
- automated testing;
- -Wall -Wextra, and -Weverything with some exceptions;
- address, memory, thread, and undefined sanitizers;
- fuzzing (at least some sort of), coverage-guided fuzzing with sanitizers;
- static analysis, starting with clang-tidy;
- other static analyzers, such as Coverity, CodeQL - have the least priority.
An example of how everything of the above, everywhere, all at once is applied in public can be seen in the ClickHouse repository: https://github.com/ClickHouse/ClickHouse https://github.com/ClickHouse/ClickHouse in the per-commit checks. But keep in mind that the checks are really heavy - run for multiple hours, and we have to apply kludges to support GitHub Actions with spot instances...
Also the dashboard can be checked here: https://aretestsgreenyet.com/ https://aretestsgreenyet.com/
- wahern 4y agoC 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.
- tmtvl 4y agoI like adding -pedantic to -Wall and -Wextra, although getting other people's software to compile with that is a nightmare.
- shrimp_emoji 4y agoYep, like your GUI framework's. It's great how unsafe code rolls downhill and forces yours to be less safe. :p