On Tue, Apr 17, 2018 at 4:35 PM, Martin Wilck <mwi...@suse.com> wrote: > Sparse emits errors about ilog2() in array indices because of the use of > __ilog2_32() and __ilog2_64(),
If sparse warns about it, then presumably gcc with -Wvla warns about it too? And if thats the case, then __builtin_constant_p() and a ternary operation isn't good enough, because gcc -Wvla is even more anal than sparse is. Which is why we have that __is_constexpr() magic for min/max(). So I suspect that what you'd want is #define ilog2(n) \ __builtin_choose_expr(__is_constexpr(n), \ const_ilog2(n), \ __builtin_choose_expr(sizeof(n) <= 4, \ __ilog2_u32(n), \ __ilog2_u64(n))) or something. Hmm? Linus