[llvm-bugs] [Bug 37155] New: Clang fails to warn on dodgy logical expression code that VC++ does warn on

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Apr 17 11:55:23 PDT 2018


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

            Bug ID: 37155
           Summary: Clang fails to warn on dodgy logical expression code
                    that VC++ does warn on
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: brucedawson at chromium.org
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org

The code below, if compiled with VC++ 2017 with /W4:

bool Test(int i) {
  return i == 2 | i == 3;
}

gives this warning:

warning.cpp(2): warning C4554: '|': check operator precedence for possible
error; use parentheses to clarify precedence

It would be nice if clang gave a similar warning. There isn't actually a bug,
but using | instead of || can certainly be confusing.

-- 
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/20180417/36070fd2/attachment.html>


More information about the llvm-bugs mailing list