Re: regarding type promotion

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

 



I should have included the program source.

H.


hchapman@anthrax:~$ cat a.c
#include <stdio.h>

int main()
{
 unsigned int value = 1;
#define BITSET 0x1234

// Wrong: always true if value is odd since BITSET == BITSET is evaluated first
 if (value & BITSET == BITSET)
 {
   printf("One\n");
 }

 // Right:
 if ((value & BITSET) == BITSET)
 {
   printf("Two\n");
 }

 return(0);
}


[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