https://bugs.linaro.org/show_bug.cgi?id=2828

--- Comment #5 from Yi He <yi...@linaro.org> ---
Hi, Petri

Since the algorithm is:

1 << total bits - leading zero bits(x - 1)

__builtin_clz's parameter is (unsigned int), so the total bit number need to be
calculated as 4 * sizeof(unsigned int) otherwise input an unsigned long will
result incorrect calculation, for example:

   unsigned long i = 1024:

   1 << (8 * sizeof(i) - __builtin_clz(1024 - 1))
-> result: 1 << 42, too big.

   for unsigned long, __builtin_clzl need to be used.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Reply via email to