[llvm-bugs] [Bug 31201] New: Implement -Wint-in-bool-context

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Nov 29 00:36:43 PST 2016


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

            Bug ID: 31201
           Summary: Implement -Wint-in-bool-context
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: sylvestre at debian.org
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

gcc has a new warning: -Wint-in-bool-context

For example, this code:
#include <assert.h>
void foo() {
    int a=0, b=0;
    assert(a <= b ? 2 : 3);
}

Will returns:
foo.c:4:19: error: ?: using integer constants in boolean context, the
expression will always evaluate to 'true' [-Werror=int-in-bool-context]
     assert(a <= b ? 2 : 3);
                   ^

When clang-4.0 -Wall will not show anything

-- 
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/20161129/eeed3feb/attachment.html>


More information about the llvm-bugs mailing list