[llvm-bugs] [Bug 37810] New: [CLANG][warnings] With -Wextra the compiler should emit a warning when enumerator and non-enumerator both appear in conditional expression

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Jun 14 15:57:54 PDT 2018


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

            Bug ID: 37810
           Summary: [CLANG][warnings] With -Wextra the compiler should
                    emit a warning when enumerator and non-enumerator both
                    appear in conditional expression
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: konstantin.belochapka at sony.com
                CC: llvm-bugs at lists.llvm.org

If extra warnings are enabled ( -Wall is passed as input to clang)
the compiler should warn when a enumerator and a non-enumerator both appear in
a conditional
expression.

Given the following example:

////////////////////////////
enum E { A, B };
int f1(void *p) {
  float x=0;
  x += (p!=0) ? 2.0: B;
  return x;
}
///////////////////////////

$clang test.cpp -Wall -c
  // No warnings generated.

$clang test.cpp -Wall -Wextra -c
  // No warnings generated.

While

$g++ test.cpp -Wall -c
  // No warnings generated.

$g++ test.cpp -Wall -Wextra -c
test.cpp: In function ‘int f1(void*)’:
test.cpp:5: warning: enumeral and non-enumeral type in conditional expression

-- 
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/20180614/b378aec5/attachment-0001.html>


More information about the llvm-bugs mailing list