On 12/14/18 4:09 AM, Reuben Thomas wrote:
As far as I can tell, the following warning is not dependent on my code, as it's inside a function in count-leading-zeros.h. Warning obtained with GCC 7.3.0:

bits_util.c: In function ‘smite_find_msbit’:
../lib/count-leading-zeros.h:39:26: warning: assuming signed overflow does not occur when simplifying conditional to constant [-Wstrict-overflow]
   return x ? BUILTIN (x) : CHAR_BIT * sizeof x;
../lib/count-leading-zeros.h:100:3: note: in expansion of macro ‘COUNT_LEADING_ZEROS’    COUNT_LEADING_ZEROS (__builtin_clzl, _BitScanReverse, unsigned long int);

The warning could stem from your code, if your code calls count_leading_zeros (E) where E's value depends on a computation that could involve signed integer overflow (which means behavior is undefined so GCC can optimize the if-then-else away and pretend it yields 0 or whatever else it likes). The warning almost surely does not stem from the underlined expression (CHAR_BIT * sizeof x), as that expression should evaluate to 32 or 64 on current platforms and this doesn't involve integer overflow.

Reply via email to