http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46509
Summary: -Wparentheses shouldn't warn about: A || Y && "foo"
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: [email protected]
ReportedBy: [email protected]
Per the subject, -Wparentheses shouldn't warn about possible ||/&& precedence
issues if the operand to the or is always false or the operand to && is always
true. These should not warn:
if (a || b && 1)
if (0 || a && b)
They shouldn't warn because even if the user is confused about precedence, the
order of evaluation doesn't affect the result of the computation.
This happens to come up frequently for coding standards that use messages in
asserts, e.g.:
assert(A == 1 || A == 3 && "some reason this property should hold");
-Chris