http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50705
--- Comment #9 from SK <santoshkumar.a at gmail dot com> 2011-10-14 16:26:38
UTC ---
Below is another scenario::
test_bit called with args
PG_slab = 7;
page->flags = 0xc0;
test_bit(PG_slab, &page->flags) returns value 0. This is used by PageSlab in
linux kernel.
/**
* test_bit - Determine whether a bit is set
* @nr: bit number to test
* @addr: Address to start counting from
*/
static inline int test_bit(int nr, const volatile unsigned long *addr)
{
return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1)));
}
but if i modify the return as
return (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG-1)));
the results are as expected, which i dont understand.
Also in all the scenarios that i reported earlier the bitwise AND is in between
a variable and a constants.