meelgroup / ganak

The first scalable probabilistic exact counter
MIT License
25 stars 6 forks source link

make LogTable always signed char #23

Closed benlorenz closed 1 year ago

benlorenz commented 1 year ago

char is signed by default on x86 but unsigned on some ARM platforms and the table needs to contain -1. This leads to errors like this:

src/component_types/base_packed_component.h: In static member function ‘static unsigned int BasePackedComponent::log2(unsigned int)’:
src/component_types/base_packed_component.h:128:10: error: narrowing conversion of ‘-1’ from ‘int’ to ‘char’ inside { } [-Wnarrowing]

This was discovered when building GANAK for julia (Yggdrasil) at https://github.com/JuliaPackaging/Yggdrasil/pull/6393 for the following platforms:

aarch64-apple-darwin aarch64-linux-gnu aarch64-linux-musl armv6l-linux-gnueabihf armv6l-linux-musleabihf armv7l-linux-gnueabihf armv7l-linux-musleabihf i686-linux-gnu i686-linux-musl powerpc64le-linux-gnu x86_64-apple-darwin x86_64-linux-gnu x86_64-linux-musl

Two more minor fixes that were necessary will follow in separate PRs.

cc: @lkastner

msoos commented 1 year ago

WOW that's some seriously good catch! Thank you!