News for hackers. Stuff that matters.
Re:Dennis Ritchie on the priorities of && || vs. == etc. (1982) by LeifCarrotson on Friday January 05, 2024 @06:07PM (#38886293)
> 1+1=1?

True + True = True, because "true" means "not zero" and "false" means "zero". In most all languages that permit int->bool casting, if(2) will evaluate to "true".

The warnings clang and FCC generate are a style warning because it's unclear on casual reading. Even readers who know the precedence rules will typically want to insert the parentheses manually. If the meaning were undefined, the compiler would give an error, not a warning.

Re:Dennis Ritchie on the priorities of && || vs. == etc. (1982) by hinkley on Friday January 05, 2024 @06:49PM (#38886684)
It’s true as long as you don’t chain more than a couple billion Boolean checks.

More importantly, only if you don’t rely on short circuiting logic.