https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109820
Bug ID: 109820 Summary: False-positive in tautological-compare Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: ansuelsmth at gmail dot com Target Milestone: --- Created attachment 55058 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=55058&action=edit preprocessed file Hi, while having fun with fixing some compilation warning to enforce WERROR on kernel linux I faced this interesting false-positive warning. The simple repro code is this #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdint.h> int main() { uint32_t test; if (((test >> 4) & 0x15) == 0x9) return 1; return 0; } Compiled with gcc -o test test.c -Wall -Werror Result in warning test.c: In function ‘main’: test.c:10:34: error: bitwise comparison always evaluates to false [-Werror=tautological-compare] 10 | if (((test >> 4) & 0x15) == 0x9) | ^~ cc1: all warnings being treated as errors Decreasing the 0x9 to something like 0x5 mute the warning. It's either a false positive or a warning that gets not triggered in some corner case. I have attached the .i as asked in the guidelines. Don't know if -v is needed. This is simple gcc installed from ubuntu devel I also verified that this is present in gcc 13.1