https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92021
Bug ID: 92021
Summary: no warning with -Wlogical-op
Product: gcc
Version: 7.4.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: tangyixuan at mail dot dlut.edu.cn
Target Milestone: ---
gcc-7.4 falls to emit the warning for the following:
$ cat s.c
int main(){
unsigned long a = 8UL;
if(~a || a){
}
return 0;
}
$ gcc-7.4 -Wlogical-op s.c
Target: x86_64-unknown-linux-gnu
Thread model: posix
When compiled with higher version, warnings such as:
$ gcc-8.3 -Wlogical-op s.c
s.c: In function ‘main’:
s.c:3:8: warning: logical ‘or’ of collectively exhaustive tests is always true
[-Wlogical-op]
if(~a || a){
^~
I do not know whether the GCC-7.4 has been maintained. If hasn't, please tell
me and treat the bug as fixed in the higher version.