http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46582
Summary: No warning is given about always false condition and
unreachable code
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c
AssignedTo: [email protected]
ReportedBy: [email protected]
GCC 4.5.x and 4.6.0 do not warn that ((x & 0xff) < 0) is always false and goo()
is never called:
======== bug.c =========
extern void goo(void);
extern int x;
int main(void)
{
if ((x & 0xff) < 0)
goo();
return 0;
}
========================
GCC 4.4.x with `-Wunreachable-code' gives a warning:
bug.c: In function 'main':
bug.c:7: warning: will never be executed
No warnings with `-Wlogical-op'.