Andrew Haley <a...@redhat.com> writes: > On 04/05/2012 01:28 PM, Michael Veksler wrote: > >> As for specific warnings, I hate that the the code (a&&b || c&&d), >> which did not cause a warning on older gcc version now gives a >> warning. I would not want it on by default since it forces users to >> write too many parentheses in ((a&&b)||(c&&d)) which makes the >> expression less readable. What next? Warn about (a*b+c*d) ? I would >> hate to write ((a*b)+(c*d)). >> >> Sure, the precedence of: << vs. +; & vs. == ; & vs. && ; is less >> clear and deserves a warning, but: & vs. | ; && vs. || ; are at >> least as common as * vs. + that programmers ought to know them. > > Absolutely so, yes. I'd consider this a bug in gcc, just as if it > warned for arithmetic.
This one is an interesting case, since there are strong arguments on both sides. I enabled the C++ warning about the precedence of && and || (it's been in C for many years). It found real bugs in real code, bugs that had existed for years. Ian