On 04/27/2015 08:47 AM, Marek Polacek wrote:
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...
Can you file a bug for this for future reference? We may not tackle this specific issue in the current iteration of delayed folding, but it certainly helps to have BZs for specific issues that we'd like to fix once we can delay folding.

jeff

Reply via email to