Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I 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.



Indeed. 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.


Uhh, 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 ==).


You 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.


Putting 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.


Well, 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




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: