Since 2015-04-21 Marek Polacek <polacek@redhat.com> 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.
Sorry. I'll look into that.
In the ML I wrote: 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 Thus unassigning for now.
For C++ delayed folding this issue won't be warned anymore, as for it sizeof isn't folded early.
GCC 6.1 has been released.
GCC 6.3 is being released, adjusting target milestone.
GCC 6.4 is being released, adjusting target milestone.
(In reply to Kai Tietz from comment #3) > For C++ delayed folding this issue won't be warned anymore, as for it sizeof > isn't folded early. With -fsanitize=integer-divide-by-zero, the spurious warning is still issued in C++.
GCC 9 branch is being closed
GCC 10.4 is being released, retargeting bugs to GCC 10.5.
GCC 10 branch is being closed.
GCC 11 branch is being closed.