On Tue, 2025-03-18 at 19:23 +0000, Scott Ashcroft wrote: > That only leaves the cxxrtl tests failing. I don't think fixing them > will be as straightforward.
Once I figured out what the test was trying to do it turned out to be quite simple. It is trying to compare the cxxrtl versions of some operations to the standard ones. One of these is 'count leading zeros' or clz. The standard version they chose to test against is __builtin_clzl but they used it on a uint64_t. That's fine on 64-bit arches where longs are 64-bit but on 32-bit and if gives the wrong answers. If it was just for Debian I'd would have swapped to __builtin_clzg which works all this stuff out but that's only arrived in gcc-14. If it was just for Linux then always using __builtin_clzll would probably work as long longs are 64-bit. But since upstream support Windows and Mac OSX I went with the equivalent of: if long is 32-bit use __builtin_clzll else use _builtin_clzl If we can get the three fixes accepted upstream 32-bit should build and pass all tests. Cheers, Scott
--- tests/cxxrtl/test_value_fuzz.cc 2025-03-18 18:38:41.872611440 +0000 +++ /home/scott/test_value_fuzz.cc 2025-03-18 21:36:35.007074547 +0000 @@ -241,7 +241,10 @@ { if (a == 0) return bits; - return __builtin_clzl(a) - (64 - bits); + if (sizeof(long) == 4) + return __builtin_clzll(a) - (64 - bits); + else + return __builtin_clzl(a) - (64 - bits); } template<size_t Bits>