lgamma test failing (nan) with clang 19 on arm64
The lgamma test at
https://github.com/xtensor-stack/xsimd/blob/a9d021ac8cd5d5d8c55458d27aa4f243dd63df66/test/test_xsimd_api.cpp#L631
is failing with clang 19 on arm64, see debian test log https://ci.debian.net/data/autopkgtest/unstable/arm64/x/xsimd/54522214/log.gz from https://ci.debian.net/packages/x/xsimd/unstable/arm64/
2885s Start 1: test_xsimd
2885s
2885s 1: Test command: /tmp/autopkgtest-lxc.8mniqst8/downtmp/build.OlH/src/test/run_test_clang_complex/test_xsimd
2885s 1: Working Directory: /tmp/autopkgtest-lxc.8mniqst8/downtmp/build.OlH/src/test/run_test_clang_complex
2885s 1: Test timeout computed to be: 10000000
2885s 1: [doctest] doctest version is "2.4.11"
2885s 1: [doctest] run with "--help" for options
2885s 1: ===============================================================================
2885s 1: /tmp/autopkgtest-lxc.8mniqst8/downtmp/build.OlH/src/test/test_xsimd_api.cpp:755:
2885s 1: TEST CASE: [xsimd api | float types functions]<xsimd::batch<float>>
2885s 1: lgamma
2885s 1:
2885s 1: /tmp/autopkgtest-lxc.8mniqst8/downtmp/build.OlH/src/test/test_xsimd_api.cpp:631: ERROR: CHECK_EQ( extract(xsimd::lgamma(T(val))), std::lgamma(val) ) is NOT correct!
2885s 1: values: CHECK_EQ( -nan, 0 )
2885s 1:
2885s 1: ===============================================================================
2885s 1: [doctest] test cases: 320 | 319 passed | 1 failed | 0 skipped
2885s 1: [doctest] assertions: 8293 | 8292 passed | 1 failed |
2885s 1: [doctest] Status: FAILURE!
2885s 1/1 Test #1: test_xsimd .......................***Failed 0.55 sec
So, apparently xsimd::lgamma(2) is returning -nan instead of 0 when compiled with clang 19 on arm64. Perhaps it's a bug in clang, not xsimd.
For comparison, the same test is passing with gcc 14 (at 1733s in the same test log). clang 19 is passing on amd64.
Separately, I'm concerned that many tests, nearly all in fact, use equality (CHECK_EQ) to make floating point comparisons. They would want to be used with doctest::Approx, as a couple of the tests are doing. Using equality for floating point comparison inevitably fails. However in this case the bigger problem is the nan value returned, not the floating point comparison.
I noticed that 6c86b23162e6b2bd0a9bba5bcdd846e3902c26a3 fixed undefined behavior in lgamma, and the fix hasn't been released yet. Could this be it?
@JohanMabille you usually handle releases, can you do this, or do you want me to make that one?
I can confirm that patch fixes the issue
https://ci.debian.net/packages/x/xsimd/unstable/arm64/ https://ci.debian.net/packages/x/xsimd/unstable/arm64/54747163/#L8543
Edit: wait, no another Debian developer set it back to clang-18. Will have to test separately.
And confirming now the patch does fix it for clang-19 https://ci.debian.net/packages/x/xsimd/unstable/arm64/55038636/#L8536
we made a new release that integrates the patch, let's close?