While digging through a problem with OpenAFS on Linux S/390, I found that gcc
uses a builtin version of the ffs() (find-first-set bit in a word) function,
unless -ansi or -fno-builtin is used as option.  That builtin version of the
ffs() function seems to be inconsistent with versions found in the Linux
kernel (asm-s390/bitops.h) and in the C library (verified against glibc-2.2.4).
It is supposed to return the bit position of the first bit that is set in the
given word, with LSB being 1, and MSB being 32.

The implementation that is used for the gcc builtin version returns 32 when
0x80000001 is passed in as word, whereas both the kernel implementation and
the C library version return 1 as expected.

Is there a specific reason for the current implementation in gcc, or is it an
actual bug?  If so, who can fix it? :-)

        Kris

Reply via email to