by user5994461 · 9y ago · 0 comments
There are no superfluous parenthesis warnings in GCC and MSVC.
$ 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 ==).The warning here couldn't be more justified. In a decent language, this should be a hard error.
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