Warning Behavior

Paolo Bonzini paolo.bonzini@lu.unisi.ch
Tue Aug 23 07:09:00 GMT 2005


Ivan Novick wrote:
> Hello,
> 
> How come the following code would not be considered a Warning?
> 
> Surely there is no possible way this would be intentional?
> 
> if (x<4);
> 	x++;

When you consider macro expansion, it could:

#if SIZEOF_LONG == 4
#define WARN_FOR_BIG_VALUES \
   printf ("hey, x is too big, keeping low bits only!")
#else
#define WARN_FOR_BIG_VALUES /* nothing */
#endif

...

long f (long long x)
{
   if (x > LONG_MAX)
     WARN_FOR_BIG_VALUES;

   return x & LONG_MAX;
}

(I'm not saying this is good code).

Paolo



More information about the Gcc mailing list