3 ms·
Won't gcc complain if you assign a variable within an if-statement?
by widforss 6y ago
Won't gcc complain if you assign a variable within an if-statement?
- GuB-42 6y agoNot if you surround the expression with extra parenthesis. And that's what they did here. Assignments in if-statement can be useful, and that's how you prevent the compiler from complaining. That warning is intended for honest mistakes, not to catch backdoors.
- tsbinz 6y agoThe parentheses here aren't actually "extra", without them the meaning would change - since && binds tighter than = without the parentheses the left hand side of = would not be an lvalue and compilation would fail.