https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65891
Bug ID: 65891
Summary: -Wlogical-op now warns about logical ‘and’ of equal
expressions even when different types/sizeofs are
involved
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: gerald at pfeifer dot com
CC: polacek at redhat dot com
Target Milestone: ---
Since 2015-04-21 Marek Polacek <[email protected]>
PR c/63357
* c-common.c (warn_logical_operator): Warn if the operands have the
same expressions.
we also diagnose code the following
typedef int r_fun_t (int);
r_fun_t * text_funcs[] = {0,0,0};
int report (unsigned t)
{
typedef int s_fun_t (long, char);
static s_fun_t * GUI_funcs[3];
return (t < sizeof text_funcs / sizeof text_funcs[0] &&
t < sizeof GUI_funcs / sizeof GUI_funcs[0]);
}
with
input: In function ‘report’:
input:8:58: warning: logical ‘and’ of equal expressions [-Wlogical-op]
return (t < sizeof text_funcs / sizeof text_funcs[0] &&
^
when these two conditions are about two different types, defined in two
different locations, and the sizes are set differently.