4 ms·
> Also, before upgrading the compilers on CI you need to fix any new warnings. But this isn’t a bad thing. It's, in fact, downright stupid and means you're wri
by kazinator 9y ago
> Also, before upgrading the compilers on CI you need to fix any new warnings. But this isn’t a bad thing.
It's, in fact, downright stupid and means you're writing in a different programming language with each compiler upgrade and at the mercy of some poorly-considered third-party opinions.
Many compiler warnings are just stylistic. They can even contradict each other. Compiler A says, "suggest parentheses here". Oops, compiler B doesn't like it: "superfluous parentheses in line 42".
As a rule of thumb, warnings that aren't finding bugs aren't worth a damn.
The proper engineering approach is to evaluate newly available warnings and try them. Keep any that are uncovering real problems, or could prevent future ones; enable those and not any others.
Warnings are just tools. You pick the tools and control them, not the other way around.
Every code change carries risk!
- paol 9y agoRead the article. They choose which warnings are considered fatal.
- gommm 9y agoThey do say this at the start: > Choose with some care which warnings end up fatal. Don’t be afraid to modify your choices as time goes on. So, my understanding is that they didn't make all warnings fatal. Only the ones they believe are important.
- user5994461 9y agoI don't know what languages you are thinking but firefox is mostly C and C++. There are no superfluous parenthesis warnings in GCC and MSVC.
- kccqzy 9y agoIndeed. I just never really internalized all the operator precedence in C/C++ so I never write code like `a + b >> c`; I always add parenthesis when mixing arithmetic and bit operations.
- zoodlep 9y agoUhh, perhaps I'm not parsing your claim correctly, but that warning most certainly does exist in gcc. $ gcc -Wall test.c test.c: In function ‘main’: test.c:6:5: warning: suggest parentheses around assignment used as truth value [-Wparentheses] if (a = b) { ^ Parentheses here would be superfluous, but would perhaps confirm you really intended to assign (i.e. used = instead of ==).
- asveikau 9y agoPutting parens around that example, while not strictly needed, also makes it harder to forget to add them if you later add an && or || to the conditional. So I am in favor.
- user5994461 9y agoYou realize that you have an assignment instead of a comparison? The warning here couldn't be more justified. In a decent language, this should be a hard error.
- steveklabnik 9y agoWell, Firefox does have more and more Rust now... fn main() { if (true) { } } results in warning: unnecessary parentheses around `if` condition --> <anon>:2:8 | 2 | if (true) { } | ^^^^^^ | = note: #[warn(unused_parens)] on by default