This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/65423] New: No warning on always-true/false predicates containing bitwise operations
- From: "chengniansun at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 14 Mar 2015 09:45:49 +0000
- Subject: [Bug c/65423] New: No warning on always-true/false predicates containing bitwise operations
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65423
Bug ID: 65423
Summary: No warning on always-true/false predicates containing
bitwise operations
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: chengniansun at gmail dot com
The condition "(a & 9) == 4" is always false, and it will be great if Gcc can
emit a warning on this.
$: cat bitwise.c
int f(int a) {
if ((a & 9) == 4) {
return 1;
} else {
return 0;
}
}
$: clang-trunk -Wtautological-compare -c bitwise.c
bitwise.c:2:15: warning: bitwise comparison always evaluates to false
[-Wtautological-compare]
if ((a & 9) == 4) {
~~~~~~~~^~~~
1 warning generated.
$: gcc-trunk -Wall -Wextra -Wtype-limits -c bitwise.c