Hi,

There are few places in VPP (most notable when trying to convert a netmask
into a length) that can pass 0 (zero) into min_log2 and expect to get a
meaningful result.

Obviously log2(0) is undefined. It turns out that this also applies to the
return of min_log2. Under the hood the function uses __builtin_clzl, and
the return of that function is also undefined for input 0.

 __builtin_clzl  could be replaced with __builtin_ia32_lzcnt_u64 on
supported CPUs to avoid the undefined behaviour. That would still not fix
the problem that passing 0 into a log function is broken by design.

Any comments?
Andreas

-- 

Andreas Schultz
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#16324): https://lists.fd.io/g/vpp-dev/message/16324
Mute This Topic: https://lists.fd.io/mt/74155196/21656
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to