On Sat, Apr 25, 2015 at 10:18:59PM +0200, Gerald Pfeifer wrote: > 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.)
I'm afraid there isn't an easy solution to this; the problem is that we fold sizeof early, so the warning sees t < sizeof 4 && t < 4 and warns. Maybe using SIZEOF_EXPR would help... Marek