Re: How to force gcc warn the conditions which are true of false forever?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Pan ruochen wrote:
Hi All,

gcc (version 3.4.5) will optimize the following code without any
warnings even with -Wall options
--------------------------------------
if (id < 0 && id > 3)
{
          printf("Failed.\n");
          return ;
}
--------------------------------------
How should I do if I do want gcc to give warnings about these code,
since in most cases
such code are really mistakes?
Then what of usages like this?

#define DEBUG_MODE 0

if (id<0 && DEBUG_MODE) {
   printf("Failed.\n");
   return;
}

This expression can never be satisfied either.

Cheers,
Nicholas Sherlock

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux