[llvm-bugs] [Bug 38571] New: -Wconstant-logical-operand and yoda conditions

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Aug 14 16:33:14 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=38571

            Bug ID: 38571
           Summary: -Wconstant-logical-operand and yoda conditions
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: ndesaulniers at google.com
                CC: llozano at chromium.org, llvm-bugs at lists.llvm.org,
                    srhines at google.com

void foo(int x) {
    if (x && 5) {}
    if (5 && x) {}
}

The above produces -Wconstant-logical-operand for the first statement, but not
the second.

This was observed while compiling the Linux kernel, as a single translation
unit has a mix of which side the constant logical operand is on, but only some
of the conditionals producing warnings.  In these cases, the constant logical
operand is nested a few macros deep.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180814/e966d1b1/attachment.html>


More information about the llvm-bugs mailing list