Hacker News new | past | comments | ask | show | jobs | submit login

A simple case is the warning clang will generate for:

  int err = 0;
  if (err = f()) {
  }
This is indeed a useful warning, as it's common to mistype == as = in this situation, but it's also absolutely correct code, and the idiom that silences the warning (surrounding with extra parentheses) does not change anything about the correctness of the code.



A hint could be that you're initializing to zero a local just to overwrite it. Not an error or a warning but it could hint that you did not mean to, isn't it ?


The initialization is just an example to show that err is a previously declared variable. The actual code could easily be different, but the warning is emitted on seeing the assignment in the conditional.




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

Search: