4 ms·
The reason for this decision is so that compiler upgrades with -Wall and -Werror don't break builds. I can see the reason behind it, but I feel that this behav
by rocqua 5y ago
The reason for this decision is so that compiler upgrades with -Wall and -Werror don't break builds.
I can see the reason behind it, but I feel that this behavior is something you opt into when you use -Werror.
- derefr 5y ago> The reason for this decision is so that compiler upgrades with -Wall and -Werror don't break builds. It feels like the "right thing" here would instead be for the compiler to allow build scripts to reference a specific point-in-time semantics for -Wall. For example, `-Wall=9.3.0` could be used to mean "all the error checks that GCC v9.3.0 knew how to run". Or better yet (for portability), a date, e.g. `-Wall=20210720` to mean "all the error checks built into the compiler as of builds up-to-and-including [date]." To implement this, compilers would just need to know what version/date each of their error checks was first introduced. Errors newer than the user's specifier, could then be filtered out of -Wall, before -Wall is applied. With such a flag, you could "lock" your CI buildscript to a specific snapshot of warnings, just like you "lock" dependencies to a specific set of resolved versions. And just like dependency locking, if you have some time on your hands one day, you could "unlock" the error-check-suite snapshot, resolve all the new error-checks introduced, and then re-lock to the new error-check-suite timestamp.
- HanyouHottie 5y agoMSVC has this[1]. .NET code analyzers are also versioned[2]. [1]:https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warnings-by-compiler-version https://docs.microsoft.com/en-us/cpp/error-messages/compiler... [2]:https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/overview#latest-updates https://docs.microsoft.com/en-us/dotnet/fundamentals/code-an...
- antoinealb 5y agoI think it might be more of an headache: what if somebody fixes a bug in an analyzer so that it catches things it used to miss ? Should it be a breaking change ? Personally i would vote for "Wall with Werror" means no guarantee for your build.
- wheybags 5y agoThe real solution: leave Werror off by default, activate it only during CI builds
- derefr 5y agoThat's even worse, because then an upgrade to the compiler in the managed CI runner (e.g. Github Actions') base-image will translate to the same version of the code failing where it previously succeeded, with nobody sure why. At least with -Werror on at all times, devs will tend to upgrade before the very-stable CI environment does, and thereby catch the problem at development time (usually less time-pressure) rather than release-cutting time (usually more time-pressure, esp. if the release is a hotfix.) ----- Mind you, it does work to enable -Werror only in CI, if you lock your CI environment / compiler Docker image / etc. to a specific stable version, and treat that as the thing to re-lock in place of the "error-check suite snapshot version." This has the disadvantage, though, that you can't take advantage of newly-stable/newly-unstable language features, or of newly-introduced compiler optimizations, without biting the bullet and taking on the work of fixing the errors introduced by re-locking the base-image. With a separate flag for locking down the error-check-suite snapshot version, you could continue to upgrade the compiler — and thereby get access to new features / optimizations — while staying on a particular build regression "scope."
- account42 5y ago> That's even worse, because then an upgrade to the compiler in the managed CI runner (e.g. Github Actions') base-image will translate to the same version of the code failing where it previously succeeded If you don't want your build to fail on warnings, don't use -Werror. If you want it to only fail on specific warnings, use -Werror=... > with nobody sure why Unless they look at the errors in the compiler output. What does it matter if it was brought on by a compiler update or a push? > At least with -Werror on at all times, devs will tend to upgrade before the very-stable CI environment does Nothing wrong with -Werror for devs - the problem is when you ship code to others and leave -Werror on by default.
- GoblinSlayer 5y agoIs -Werror really supposed to not break builds?
- account42 5y agoThe whole point of -Werror is to break builds and -Wall / -Wextra are definitely not frozen. If you can't handle compiler updates resulting in errors, don't use -Werror in that environment.