> 2015-04-21 Marek Polacek > > PR c/63357 > * c-common.c (warn_logical_operator): Warn if the operands have the > same expressions. This is nice! It really helped me find an issue or two in the Wine project. Unfortunately it also causes false positives: int report (unsigned t) { typedef int r_fun_t (int); static r_fun_t * text_funcs[7]; static r_fun_t * GUI_funcs[7]; return (t < sizeof text_funcs / sizeof text_funcs[0] && t < sizeof GUI_funcs / sizeof GUI_funcs[0]); } Where we now warn as follows: input: In function ¡report¢: input:8:58: warning: logical ¡and¢ of equal expressions [-Wlogical-op] return (t < sizeof text_funcs / sizeof text_funcs[0] && ^ In case this example feels too contrived (even though it is an excerpt of Wine code), we now also warn about the following where the two types and variables are defined in different places and the size of one is set implicitly: 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]); } (I also filed this as https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65891 so that we keep track.) Gerald