Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
rcfox
· 15y ago · 0 comments
What about while? while(flag = 0) looks like a similar error, but while(foo = read()) is a common idiom.
Comments
[–]
brownleej
15y ago
I think some compilers give a warning on while(foo = read()) but not on while((foo = read())).
[–]
CamperBob
15y ago
That would be a broken compiler.
[–]
tbrownaw
15y ago
No, I'm pretty sure that's
intentional
specifically to permit that idiom.
[–]
__david__
15y ago
It's usually a warning that you have to turn on explicitly, or one that you can at least turn off (thank heavens).
[–]
CamperBob
15y ago
It's not the choice of keyword that (should) trigger the warning. It's the simple fact that an expression that evaluates to boolean contains an '='. This potential error is trivial for any compiler to flag.