https://llvm.org/bugs/show_bug.cgi?id=26852
Bug ID: 26852 Summary: false negative for -Wconstant-logical-operand in C++ mode, not in C Product: clang Version: unspecified Hardware: PC OS: Linux Status: NEW Severity: normal Priority: P Component: -New Bugs Assignee: unassignedclangb...@nondot.org Reporter: ed0.88.p...@gmail.com CC: llvm-bugs@lists.llvm.org Classification: Unclassified Consider this snippet code: $ cat enum_constant_operand.cpp int bar(); typedef enum { X = 1, Y = 2, Z = 4, } val_t; int foo() { int val = bar(); return (val == X || Y || Z); } EOF If it's compiled in C mode, it reports: $ clang++ -x c enum_constant_operand.cpp -fsyntax-only enum_constant_operand.cpp:13:19: warning: use of logical '||' with constant operand [-Wconstant-logical-operand] return (val == X || Y || Z); ^ ~ enum_constant_operand.cpp:13:19: note: use '|' for a bitwise operation return (val == X || Y || Z); ^~ | enum_constant_operand.cpp:13:24: warning: use of logical '||' with constant operand [-Wconstant-logical-operand] return (val == X || Y || Z); ^ ~ enum_constant_operand.cpp:13:24: note: use '|' for a bitwise operation return (val == X || Y || Z); ^~ | 2 warnings generated. $ If it's compiled in C++, it won't report anything: $ clang++ enum_constant_operand.cpp -fsyntax-only $ -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs